public static void Punch(GameObject gObj, Direction direction) { Vector2Int?frontCoord = GetFrontCoordinate(Global.GetObjectCoordinates(gObj), direction); if (frontCoord == null) { return; } else { Floor.Coordinates coordinates = Floor.GetCoordinates(frontCoord.Value).Value; Debug.Log(coordinates.contentEntity); if (coordinates.contentEntity == Entity.BOMB) { Bomb.BombController bomb = coordinates.content.GetComponent <Bomb.BombController>(); if (bomb.gameObject.layer == 10 || bomb.gameObject.layer == 11) { bomb.Throw(direction, 3); } else { Debug.Log("KICKED NEW BOMB"); } } } }
// Gloves private void LiftUpBomb(GameObject bomb) { var bombCtrl = bomb.GetComponent <Bomb.BombController>(); // Set coordinate to Empty Floor.SetCoordinatesContent(Global.GetObjectCoordinates(bomb), null, Entity.NONE); // Carry bomb bombCtrl.SetBombStatus(Bomb.State.CARRIED); bombCtrl.gameObject.transform.Translate(new Vector3(0, 10, 0)); bombCtrl.transform.parent = playerController.transform; this.hasLiftedBomb = true; this.liftedBomb = bombCtrl; }
private Direction GetKickDirection(Bomb.BombController bomb) { if (playerController.GetDirection() == Direction.NORTH && playerController.transform.position.z < bomb.transform.position.z - 5) { return(Direction.NORTH); } if (playerController.GetDirection() == Direction.SOUTH && playerController.transform.position.z > bomb.transform.position.z + 5) { return(Direction.SOUTH); } if (playerController.GetDirection() == Direction.WEST && playerController.transform.position.x > bomb.transform.position.x + 5) { return(Direction.WEST); } if (playerController.GetDirection() == Direction.EAST && playerController.transform.position.x < bomb.transform.position.x - 5) { return(Direction.EAST); } return(Direction.NONE); }