public override void Start() { // do baseline start actions first... // also grabs default animation component too. base.Start(); // upon first creation, create the common "attackAI" instance Attack = this.gameObject.AddComponent<attackAI>(); Attack.attackInterval = attackInterval; Attack.attackRadius = attackRadius; Attack.damage = attackDamage; // What can scary monsters attack... Guards and Humans // and don't forget about the SafeZone houses too! Attack.AddAttackTarget(eNavTargets.Human); Attack.AddAttackTarget(eNavTargets.Guard); Attack.AddAttackTarget(eNavTargets.SafeZone); // via the "Hero Zombie" prefab, it has a child element // of "LittleHero_solo" which has animations of // L2R_swipe, walk, die, idle_lookaround, hurt Attack.AssignAnimation( gameObject, animComponent, "L2R_swipe" ); // Now, for scaring humans (or whatever else may be scared away. CastFear = this.gameObject.AddComponent<castFearAI>(); CastFear.fearInterval = fearInterval; CastFear.fearRadius = fearRadius; // Zombies have same default targets of SafeZone and Finish // only directly target zombies to safe or finish zones. // however, why dont the zombies try to target humans and guards too // maybe later defaultNavTargets.Clear(); defaultNavTargets.Add(eNavTargets.SafeZone); defaultNavTargets.Add(eNavTargets.Finish); // pick a new target from either safe vs finish possibilities moveToNewTarget(); // Initiate the zombie to walking animation //animComponent.wrapMode = WrapMode.Loop; //animComponent.Play("walk"); }
public override void Start() { // do baseline start actions first... // also grabs default animation component too. base.Start(); // upon first creation, create the common "attackAI" instance Attack = this.gameObject.AddComponent <attackAI>(); Attack.attackInterval = attackInterval; Attack.attackRadius = attackRadius; Attack.damage = attackDamage; // What can scary monsters attack... Guards and Humans // and don't forget about the SafeZone houses too! Attack.AddAttackTarget(eNavTargets.Human); Attack.AddAttackTarget(eNavTargets.Guard); Attack.AddAttackTarget(eNavTargets.SafeZone); // via the "Hero Zombie" prefab, it has a child element // of "LittleHero_solo" which has animations of // L2R_swipe, walk, die, idle_lookaround, hurt Attack.AssignAnimation(gameObject, animComponent, "L2R_swipe"); // Now, for scaring humans (or whatever else may be scared away. CastFear = this.gameObject.AddComponent <castFearAI>(); CastFear.fearInterval = fearInterval; CastFear.fearRadius = fearRadius; // Zombies have same default targets of SafeZone and Finish // only directly target zombies to safe or finish zones. // however, why dont the zombies try to target humans and guards too // maybe later defaultNavTargets.Clear(); defaultNavTargets.Add(eNavTargets.SafeZone); defaultNavTargets.Add(eNavTargets.Finish); // pick a new target from either safe vs finish possibilities moveToNewTarget(); // Initiate the zombie to walking animation //animComponent.wrapMode = WrapMode.Loop; //animComponent.Play("walk"); }
public override void Start() { manaCost = zombieManaCost; //StartCoroutine ("updateSpeedbyNearbyZombies"); lifeSpan = 5000f; // do baseline start actions first... // also grabs default animation component too. base.Start(); // upon first creation, create the common "attackAI" instance // Attack = this.gameObject.AddComponent<attackAI>(); Attack = this.gameObject.GetComponent <attackAI>(); // Now, for scaring humans (or whatever else may be scared away. // CastFear = this.gameObject.AddComponent<castFearAI>(); CastFear = this.gameObject.GetComponent <castFearAI>(); // make sure that the castFear interval is not less than the attack, // otherwise every human would be cast "afraid" before a zombie could // attack them and turn human into a zombie. if (CastFear.fearInterval < Attack.attackInterval) { // for grins add 1/100 second to delay CastFear.fearInterval = Attack.attackInterval + .01f; } // What can a Zombie attack... Guards and Humans // and don't forget about the SafeZone houses too! Attack.AddAttackTarget(eNavTargets.Human); Attack.AddAttackTarget(eNavTargets.Guard); Attack.AddAttackTarget(eNavTargets.SafeZone); // Attack successful handler, called when we hit another object. // We delegate this directly to the global handler. Attack.SuccessfulAttack += (object sender, attackAI.SuccessfulAttackEventArgs e) => globalEvents.OnEnemyElementsHit(sender, e.objectHit); // via the "Hero Zombie" prefab, it has a child element // of "LittleHero_solo" which has animations of // L2R_swipe, walk, die, idle_lookaround, hurt Attack.AssignAnimation(gameObject, animComponent, "L2R_swipe"); // Zombies have same default targets of SafeZone and Finish // only directly target zombies to safe or finish zones. // however, why dont the zombies try to target humans and guards too // maybe later defaultNavTargets.Clear(); defaultNavTargets.Add(eNavTargets.SafeZone); defaultNavTargets.Add(eNavTargets.Finish); // if all else fails, find SOME place in the playable area of the board defaultNavTargets.Add(eNavTargets.Playable); // Zombies (walk, idle_lookaround, hurt, die, L2R_swipe) AnimationClip ac = animComponent.GetClip("idle_lookaround"); ac.wrapMode = WrapMode.Loop; ac = animComponent.GetClip("hurt"); ac.wrapMode = WrapMode.Once; ac = animComponent.GetClip("die"); ac.wrapMode = WrapMode.Once; ac = animComponent.GetClip("L2R_swipe"); ac.wrapMode = WrapMode.Once; // for commonAI during "takeDamage" from attacking hasDieAnimation = true; hasHurtAnimation = true; float animSpeed = -.5f; animComponent.GetComponent <Animation>() ["die"].speed = animSpeed; float animTime = Mathf.Abs(animComponent.GetComponent <Animation>() ["die"].length * (1 / animSpeed)); animComponent.GetComponent <Animation>() ["die"].time = animComponent.GetComponent <Animation>() ["die"].length; animComponent.Play("die"); Invoke("completeInit", animTime); }
public override void Start() { manaCost = zombieManaCost; //StartCoroutine ("updateSpeedbyNearbyZombies"); lifeSpan = 5000f; // do baseline start actions first... // also grabs default animation component too. base.Start(); // upon first creation, create the common "attackAI" instance // Attack = this.gameObject.AddComponent<attackAI>(); Attack = this.gameObject.GetComponent<attackAI>(); // Now, for scaring humans (or whatever else may be scared away. // CastFear = this.gameObject.AddComponent<castFearAI>(); CastFear = this.gameObject.GetComponent<castFearAI>(); // make sure that the castFear interval is not less than the attack, // otherwise every human would be cast "afraid" before a zombie could // attack them and turn human into a zombie. if( CastFear.fearInterval < Attack.attackInterval ) // for grins add 1/100 second to delay CastFear.fearInterval = Attack.attackInterval + .01f; // What can a Zombie attack... Guards and Humans // and don't forget about the SafeZone houses too! Attack.AddAttackTarget(eNavTargets.Human); Attack.AddAttackTarget(eNavTargets.Guard); Attack.AddAttackTarget(eNavTargets.SafeZone); // Attack successful handler, called when we hit another object. // We delegate this directly to the global handler. Attack.SuccessfulAttack += (object sender, attackAI.SuccessfulAttackEventArgs e) => globalEvents.OnEnemyElementsHit(sender, e.objectHit); // via the "Hero Zombie" prefab, it has a child element // of "LittleHero_solo" which has animations of // L2R_swipe, walk, die, idle_lookaround, hurt Attack.AssignAnimation( gameObject, animComponent, "L2R_swipe" ); // Zombies have same default targets of SafeZone and Finish // only directly target zombies to safe or finish zones. // however, why dont the zombies try to target humans and guards too // maybe later defaultNavTargets.Clear(); defaultNavTargets.Add(eNavTargets.SafeZone); defaultNavTargets.Add(eNavTargets.Finish); // if all else fails, find SOME place in the playable area of the board defaultNavTargets.Add(eNavTargets.Playable); // Zombies (walk, idle_lookaround, hurt, die, L2R_swipe) AnimationClip ac = animComponent.GetClip ("idle_lookaround"); ac.wrapMode = WrapMode.Loop; ac = animComponent.GetClip ("hurt"); ac.wrapMode = WrapMode.Once; ac = animComponent.GetClip ("die"); ac.wrapMode = WrapMode.Once; ac = animComponent.GetClip ("L2R_swipe"); ac.wrapMode = WrapMode.Once; // for commonAI during "takeDamage" from attacking hasDieAnimation = true; hasHurtAnimation = true; float animSpeed = -.5f; animComponent.GetComponent<Animation>() ["die"].speed = animSpeed; float animTime = Mathf.Abs ( animComponent.GetComponent<Animation>() ["die"].length * (1 / animSpeed)); animComponent.GetComponent<Animation>() ["die"].time = animComponent.GetComponent<Animation>() ["die"].length; animComponent.Play ("die"); Invoke ("completeInit",animTime); }