// Use this for initialization protected void Start() { GameObject gameObject = GameObject.Find("Unit Manager"); if (gameObject != null) { this.unitManager = gameObject.GetComponent <CommonUnitManager>(); if (this.unitManager == null) { Debug.LogError("Common: Unit Manager is not created in the editor."); } else { this.unitManager.getAllObjects().Add(this.gameObject); } } Renderer renderer = this.GetComponent <Renderer>(); this.initialColor = renderer.material.color; if (this.initialColor.Equals(Color.black)) { this.initialColor = Color.white; } Vector3 size = renderer.bounds.size; this.fieldOfViewRadius = 2.5f; this.attackRadius = Mathf.Ceil(((size / 2f).magnitude)); if (this.attackCooldown <= 3f) { this.attackCooldown = 3f; } this.canBeSelected = true; this.level = 1; this.attackPower = 1; this.maxHealth = 5; this.currentHealth = 5; //this.isEnemy = false; this.isDead = false; this.isTakingDamage = false; this.enemies = new List <CommonUnit>(); this.enemyTarget = null; }
protected void Awake() { CommonUnitManager.Instance = this; }