// Destroys this boat as well as the plant on it public void Destructor() { for (int i = 0; i < moveList.Count; i++) { if (moveList[i].CompareTag("Turbine") || moveList[i].CompareTag("Plant")) { PlantGridObject plant = moveList[i].GetComponent <PlantGridObject>(); plant.TakeDamage(500); } if (moveList[i].CompareTag("Player")) { PlayerGridObject player = moveList[i].GetComponent <PlayerGridObject>(); player.invincible = false; } } Destroy(this.gameObject); }
void OnTriggerExit2D(Collider2D col) { if (col.gameObject.CompareTag("Player")) { hasPlayer = false; PlayerGridObject player = col.GetComponent <PlayerGridObject>(); moveList.Remove(col.gameObject); player.platforms--; } if (col.gameObject.GetComponent <TurbinePlantObject>()) { hasTurbine = false; turbineMove = false; delayCounter = 0; } if (!hasPlayer && hasTurbine) { plant.TakeDamage(100); } }
// Update is called once per frame protected override void Update() { base.Update(); // TODO: pull up animator code for player up to here so monster can have their own // Get Left or Right horizontalAxis = Input.GetAxisRaw("Horizontal"); // Get Up or Down verticalAxis = Input.GetAxisRaw("Vertical"); // Up if (canMove) { if (!isAttacking && verticalAxis > 0) { Move(Globals.Direction.North); Move(Globals.Direction.North); // Double movespeed if (horizontalAxis == 0.0f) { Move(Globals.Direction.North); } } // Down else if (!isAttacking && verticalAxis < 0) { Move(Globals.Direction.South); Move(Globals.Direction.South); if (horizontalAxis == 0.0f) { Move(Globals.Direction.South); } } // Left if (!isAttacking && horizontalAxis < 0) { Move(Globals.Direction.West); Move(Globals.Direction.West); if (verticalAxis == 0.0f) { Move(Globals.Direction.West); } } // Right else if (!isAttacking && horizontalAxis > 0) { Move(Globals.Direction.East); Move(Globals.Direction.East); if (verticalAxis == 0.0f) { Move(Globals.Direction.East); } } if (!isAttacking && (horizontalAxis != 0.0f || verticalAxis != 0.0f)) { animator.SetBool("IsWalking", true); animator.SetInteger("Direction", (int)direction); } else { animator.SetBool("IsWalking", false); } } if (!canvas.dialogue && Input.GetKeyDown(KeyCode.Space)) { if (!isAttacking) { animator.SetTrigger("Attack"); Attack(); //knockBack logic foreach (KillableGridObject target in killList) { MoveableGridObject moveable = target.GetComponent <MoveableGridObject>(); if (moveable && target.faction == Globals.Faction.Enemy) { if (!(moveable.gameObject.GetComponent <BombObject>()) && !(moveable.gameObject.GetComponent <RollingBoulder>())) { for (int i = 0; i < this.gameObject.GetComponent <PlayerGridObject>().knockBackPower; i++) { moveable.Move(this.gameObject.GetComponent <PlayerGridObject>().direction); } } } } } } else if (!canvas.dialogue && Input.GetButtonDown("Deplant")) { switch (direction) { case Globals.Direction.South: killList = southHitCollider.GetKillList(); break; case Globals.Direction.East: killList = eastHitCollider.GetKillList(); break; case Globals.Direction.North: killList = northHitCollider.GetKillList(); break; case Globals.Direction.West: killList = westHitCollider.GetKillList(); break; } killList.RemoveAll((KillableGridObject target) => target == null); // Deal damage to all targets of the enemy faction foreach (KillableGridObject target in killList) { //deplant code MOVED so deplanting is a different button PlantGridObject plant = target.GetComponent <PlantGridObject>(); if (plant) { if (!plant.unharvestable) { plant.TakeDamage(100); } } } } else { for (int i = 0; i < 10; ++i) { if (!canvas.dialogue && Input.GetKeyDown("" + i)) { Plant(i - 1); } } } if (plantCooldown > 0) { plantCooldown--; if (plantCooldown <= 0) { canvas.UpdatePlantCooldown(true); } } }