public void damage(int damage, GameObject damager, PlayerServer playerServer) { if (!isServer) { return; } targetNetwork = playerServer; this.targetId = playerServer.connectionID; StartCoroutine(flash()); health -= damage; //Server.spawnObject(e_Objects.VFX_IMPACT_MELEE_1, new Vector3(this.transform.position.x, this.transform.position.y+0.5f, this.transform.position.z)); //GameObject o = Instantiate((GameObject)Resources.Load("Special Effects/Skills/"+this.impactHitPrefab.name)); //o.transform.position = new Vector3(this.transform.position.x, this.transform.position.y+0.5f, this.transform.position.z); //NetworkServer.Spawn(o); if (damager != null) { target = damager; } else { Debug.LogError("damager is null MobManager.cs " + damager); } if (health <= 0) { //kill(); this.state = e_States.DIE; } }
void chase() { followTarget(this.target); if (isTargetOutOfRange(this.target, 5)) { setState(e_States.IDLE); } if (canAttack()) { //Then attack lol state = e_States.ATTACK; } }
void setState(e_States newState) { this.state = newState; }