我使用Unity3d和C#,我有两个脚本:
脚本1:
using UnityEngine;
using System.Collections;
public class PlayerAttack : MonoBehaviour {
public GameObject target;
// Update is called once per frame
void Update () {
if(Input.GetKeyUp(KeyCode.F))
{
Attack();
}
}
void Attack() {
EnemyHealth eh = (EnemyHealth)target.GetComponent("EnemyHealth");
eh.HealthRulse(-10);
}
}
Run Code Online (Sandbox Code Playgroud)
脚本2:
using UnityEngine;
using System.Collections;
public class EnemyHealth : MonoBehaviour {
public int curHealth = 100;
public int maxHealth = 100;
public float healthBarLeangth;
// Use this for initialization
void Start () {
healthBarLeangth = Screen.width / 2;
} …
Run Code Online (Sandbox Code Playgroud) public StudentClass(char level, int number, Teacher educator, int maxStudents)
{
this.level = level;
this.number = number;
this.educator = educator;
this.numStudents = 0;
this.students = new Student[maxStudents];
}
public StudentClass(char level, int number)
{
this.level = level;
this.number = number;
this.numStudent = 0;
this.students = new Student[STANDART];
}
Run Code Online (Sandbox Code Playgroud)
它给我一个错误的单词 - StudentClass请帮助我....谢谢你