public override void useCard(Character actor) { //Create a reference to the node we're trying to destroy. Since we do not know the //entire grid map, we will start at the actor origin and work from there. Grid.GridNode targetNode = actor.CurrentNode; //Keep track of the hitbox in case we want to do damage when we destroy a tile. Weapons.Hitbox temp = MonoBehaviour.Instantiate(hitbox); temp.Damage = damage; temp.DeathTime = .2f; temp.transform.position = targetNode.transform.position; if (actor.Direction == Util.Enums.Direction.Left) { for (int i = 0; i < range; i++) { if (actor.CurrentNode.Left.panelExists(Util.Enums.Direction.Left)) { temp.transform.position = targetNode.Left.transform.position; targetNode = targetNode.Left; } } //Destroy the furthest tile within range. targetNode.Type = Assets.Scripts.Util.Enums.FieldType.Destroyed; } if (actor.Direction == Util.Enums.Direction.Right) { for (int i = 0; i < range; i++) { if (actor.CurrentNode.Right.panelExists(Util.Enums.Direction.Right)) { temp.transform.position = targetNode.Right.transform.position; targetNode = targetNode.Right; } } //Destroy the furthest tile within range. targetNode.Type = Assets.Scripts.Util.Enums.FieldType.Destroyed; } }
protected override void RunAI() { if (Hop && mechAnima.GetCurrentAnimatorClipInfo(0).Length > 0 && (mechAnima.GetCurrentAnimatorClipInfo(0)[0].clip.name.Equals("MoveBegin") || (mechAnima.GetCurrentAnimatorClipInfo(0)[0].clip.name.Equals("MoveEnd")))) { Hop = false; mechAnima.SetBool("Hop", false); transform.position = currentNode.transform.position; } //We change turns each second turn += Time.deltaTime; if (!hit && (!Attacking && !ResetingPosition)) { if (turn > 1f) { //mechAnima.SetBool("Hop", false); turn = 0; //If player is above us if (player.CurrentNode.Position.x < currentNode.Position.x) { //Check if we can move up. if (!currentNode.Up.Occupied) { currentNode.clearOccupied(); //Say we aren't here currentNode = currentNode.Up; //Say we're there currentNode.Owner = (this); //Tell the place we own it. mechAnima.SetBool("Hop", true); Hop = true; } } //If player is above us else if (player.CurrentNode.Position.x > currentNode.Position.x) { //Check if we can move up. if (!currentNode.Down.Occupied) { currentNode.clearOccupied(); //Say we aren't here currentNode = currentNode.Down; //Say we're there currentNode.Owner = (this); //Tell the place we own it. mechAnima.SetBool("Hop", true); Hop = true; } } //If they are in front of us, ATTACK!. else if (this.transform.position.z == currentNode.transform.position.z && this.transform.position.x == currentNode.transform.position.x) { AnimatorClipInfo[] temp = mechAnima.GetCurrentAnimatorClipInfo(0); if (temp.Length > 0 && temp[0].clip.name.Equals("SamuraiWait1")) { mechAnima.SetBool("Attack", true); sfx.PlaySong(0); Attacking = true; } } } } else if (Attacking) { if (!mechAnima.GetBool("HoldAttack") && mechAnima.GetCurrentAnimatorClipInfo(0).Length > 0) { if (mechAnima.GetCurrentAnimatorClipInfo(0)[0].clip.name.Equals("SamuraiStabEnter")) { mechAnima.SetBool("HoldAttack", true); mechAnima.SetBool("Attack", false); } } if ((player.transform.position.z + 2f) < this.transform.position.z) { transform.position = new Vector3(transform.position.x, transform.position.y, transform.position.z - 5f * Time.deltaTime); } else { ResetingPosition = true; mechAnima.SetBool("Attack", false); mechAnima.SetBool("HoldAttack", false); mechAnima.SetBool("WithdrawAttack", true); Attacking = false; Grid.GridNode t = currentNode; while (t.transform.position.z >= this.transform.position.z && t.Left != null) { t = t.Left; } Weapons.Hitbox b = Instantiate(bullet).GetComponent <Weapons.Hitbox>(); b.transform.position = t.transform.position; b.CurrentNode = t; } } else if (ResetingPosition) { AnimatorClipInfo[] temp = mechAnima.GetCurrentAnimatorClipInfo(0); if (currentNode.transform.position.z > this.transform.position.z) { transform.position = new Vector3(transform.position.x, transform.position.y, transform.position.z + 6f * Time.deltaTime); } else if (temp.Length > 0 && (temp[0].clip.name.Equals("SamuraiStabExit") || temp[0].clip.name.Equals(("SamuraiWait1")))) { mechAnima.SetBool("WithdrawAttack", false); ResetingPosition = false; transform.position = currentNode.transform.position; } } else { mechAnima.SetBool("Hurt", true); turn = 0; } }
protected void spawnObjectUsingPrefabAsModel(int damage, int distance, float deathTime, bool piercing, Util.Enums.Direction direction, float speed, int timesCanPierce, bool isFlying, Grid.GridNode spawnPosition, Player.Character actor, bool changeMaterial = false) { Weapons.Hitbox temp = MonoBehaviour.Instantiate(hitbox); GameObject model = MonoBehaviour.Instantiate(prefab); if (actor.Direction == Util.Enums.Direction.Left) { model.transform.localScale = new Vector3(model.transform.localScale.x, -model.transform.localScale.y, model.transform.localScale.z); } model.transform.parent = temp.transform; temp.Damage = damage; temp.Distance = distance == 0 ? 1 : distance; temp.DeathTime = deathTime; temp.Piercing = piercing; temp.Direction = direction; temp.Speed = speed; temp.TimesCanPierce = timesCanPierce; temp.IsFlying = isFlying; temp.Owner = actor.gameObject; temp.Element = element; Util.AddElement.AddElementByEnum(temp.gameObject, element, changeMaterial); temp.CurrentNode = spawnPosition; temp.transform.position = spawnPosition.transform.position; }
protected void spawnObjectUsingPrefabAsModel(int damage, int distance, float deathTime, bool piercing, Util.Enums.Direction direction, float speed, int timesCanPierce, bool isFlying, Grid.GridNode spawnPosition, Player.Character actor) { Weapons.Hitbox temp = MonoBehaviour.Instantiate(hitbox); GameObject model = MonoBehaviour.Instantiate(prefab); model.transform.parent = temp.transform; temp.Damage = damage; temp.Distance = distance == 0 ? 1 : distance; temp.DeathTime = deathTime; temp.Piercing = piercing; temp.Direction = direction; temp.Speed = speed; temp.TimesCanPierce = timesCanPierce; temp.IsFlying = isFlying; temp.Owner = actor.gameObject; temp.Element = element; Util.AddElement.AddElementByEnum(model, element, true); temp.CurrentNode = spawnPosition; temp.transform.position = spawnPosition.transform.position; }
protected override void RunAI() { if (Attacking && mechAnima.GetCurrentAnimatorClipInfo(0).Length > 0 && mechAnima.GetCurrentAnimatorClipInfo(0)[0].clip.name.Equals("SamuraiVerticalSlash")) { Attacking = false; mechAnima.SetBool("Attack", false); Weapons.TornadoHitbox b = Instantiate(bullet).GetComponent <Weapons.TornadoHitbox>(); b.transform.position = bulletHolster.transform.position; b.CurrentNode = bulletHolster.CurrentNode; b.zTargetDistance = bulletHolster.zTargetDistance; b.xTargetDistance = bulletHolster.xTargetDistance; b.zStartingPoint = bulletHolster.zStartingPoint; b.xStartingPoint = bulletHolster.xStartingPoint; } if (Hop && mechAnima.GetCurrentAnimatorClipInfo(0).Length > 0 && (mechAnima.GetCurrentAnimatorClipInfo(0)[0].clip.name.Equals("MoveBegin") || (mechAnima.GetCurrentAnimatorClipInfo(0)[0].clip.name.Equals("MoveEnd")))) { Hop = false; mechAnima.SetBool("Hop", false); transform.position = currentNode.transform.position; } //We change turns each second turn += Time.deltaTime; if (!hit) { if (turn > 3f) { mechAnima.SetBool("Attack", false); turn = 0; if (currentNode.Left.Type == Util.Enums.FieldType.Blue) { if (!currentNode.Left.Occupied) { currentNode.clearOccupied(); //Say we aren't here currentNode = currentNode.Left; //Say we're there currentNode.Owner = (this); //Tell the place we own it. mechAnima.SetBool("Hop", true); Hop = true; } else if (currentNode.Left.Down != null && !currentNode.Left.Down.Occupied && !currentNode.Down.Occupied) { currentNode.clearOccupied(); //Say we aren't here currentNode = currentNode.Down; //Say we're there currentNode.Owner = (this); //Tell the place we own it. mechAnima.SetBool("Hop", true); Hop = true; } else if (currentNode.Left.Up != null && !currentNode.Left.Up.Occupied && !currentNode.Up.Occupied) { currentNode.clearOccupied(); //Say we aren't here currentNode = currentNode.Up; //Say we're there currentNode.Owner = (this); //Tell the place we own it. mechAnima.SetBool("Hop", true); Hop = true; } } else if (currentNode.Up != null && !currentNode.Up.Occupied) { currentNode.clearOccupied(); //Say we aren't here currentNode = currentNode.Up; //Say we're there currentNode.Owner = (this); //Tell the place we own it. mechAnima.SetBool("Hop", true); Hop = true; } //If they are in front of us, ATTACK!. else { AnimatorClipInfo[] temp = mechAnima.GetCurrentAnimatorClipInfo(0); if (temp.Length > 0 && temp[0].clip.name.Equals("SamuraiWait1")) { Attacking = true; mechAnima.SetBool("Attack", true); sfx.PlaySong(0); Grid.GridNode t = currentNode; do { t = t.Left; } while (t.Left != null && t.Left.Type != Util.Enums.FieldType.Red); while (t.Up != null) { t = t.Up; } t = t.Right; if (t == currentNode) { t = t.Left; } Grid.GridNode s = t; while (s.Down != null) { s = s.Down; } bulletHolster.transform.position = t.transform.position; bulletHolster.CurrentNode = t; bulletHolster.zTargetDistance = player.transform.position.z; bulletHolster.xTargetDistance = s.transform.position.x; bulletHolster.zStartingPoint = t.transform.position.z; bulletHolster.xStartingPoint = t.transform.position.x; } } } } else { mechAnima.SetBool("Hurt", true); turn = 0; } }