错误CS1001:预期的标识符以及如何正确将类/方法传递给其他人

时间:2019-04-15 06:38:27

标签: c#

我正在与一小组学生合作,使用unity和c#为一个学期项目开发一个简单的游戏,任务之一是实现一个氧气系统。我想开发一种系统,这样一旦玩家越过基地的碰撞场,他们就会重新获得氧气,而一旦离开,氧气将以设定的速度消耗。设置了两个类,但是有错误提示第11行需要标识符,我也不确定我的函数是否设置为正确调用其他类的变量和函数来实现此目的,特别是因为它一直在发出信号,无法找到以前是Oxygone类。

我认为缺少一个论点,我正在寻找简单的东西,因为我在凌晨2:30筋疲力尽,但是我找不到信息来确认和补充氧气,FixedUpdate和其他变体并没有解决它。

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class scrBaseBehaviour : MonoBehaviour
{

 scrOxygone oxygen = new _scrOxygone();
    // Start is called before the first frame update
    void OnTriggerEnter2D(Collider2D other)
    {
    if (other.gameObject.tag == "Player")

            oxygen.FixedUpdate = 1;
            oxygen.FixedUpdate(oxygen);
    }

    void OnTriggerExit(Collider2D other)
    {
      if (other.gameObject.tag == "Player")
            oxygen.FixedUpdate();
    }

}

和其他包含方法和变量的文件是

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class scrOxygone : MonoBehaviour
{
    //Oxygen
    public float oxygenSeconds; //Seconds to Oxygen depletion
    /*[HideInInspector]*/public float oxygen; //Oxygen percentage
    public Text oxygenGUI; //Oxygen GUI 

   public void Start(float oxygen)
    {
        oxygen = 1;
    }



   public void FixedUpdate()
    {
        //Oxygen
        oxygen = passiveBreath(oxygen, oxygenSeconds);
        oxygenGUI.text = "Oxygen: " + Mathf.Round(oxygen * 100) + "%";
    }

  public float passiveBreath(float status, float seconds) //Oxygen 
  decreasing
    {
        if (status > 0)
            status -= Time.deltaTime / (seconds) * (100/60);
        else
            status = 0;

        return status;
    }

}

0 个答案:

没有答案