/// <summary> /// deal damage to the ship /// </summary> /// <param name="name"></param> public void TakeDamage(string name) { Debug.Log("name of ship" + name); GameObject Ship = GameObject.Find(name); PatrolBoatManager Patrolboat = Ship.GetComponent <PatrolBoatManager>(); CruiserManager cruiserManager = Ship.GetComponent <CruiserManager>(); AircraftCarrierManager aircraftship = Ship.GetComponent <AircraftCarrierManager>(); SubmarineManager submarineManager = Ship.GetComponent <SubmarineManager>(); BattleShipManager battleShipManager = Ship.GetComponent <BattleShipManager>(); if (Patrolboat != null) { Patrolboat.ShipTakeDamage(); } if (cruiserManager != null) { cruiserManager.ShipTakeDamage(); } if (aircraftship != null) { aircraftship.ShipTakeDamage(); } if (submarineManager != null) { submarineManager.ShipTakeDamage(); } if (battleShipManager != null) { battleShipManager.ShipTakeDamage(); } }
public BeginShipTile(float yBegin, float yEnd, float viewXShift, Quadrangle hitBound, int type, List <Quadrangle> collisionRectangles, bool traversable, TypeOfEnemyShip typeOfEnemyShip) : base(yBegin, yEnd, viewXShift, hitBound, type, collisionRectangles, traversable) { this.typeOfEnemyShip = typeOfEnemyShip; if (typeOfEnemyShip == TypeOfEnemyShip.PatrolBoat) { ShipOwner = new PatrolBoatManager(typeOfEnemyShip); } else if (typeOfEnemyShip == TypeOfEnemyShip.WarShip) { ShipOwner = new WarShipManager(typeOfEnemyShip); } else if (typeOfEnemyShip == TypeOfEnemyShip.Submarine) { ShipOwner = new SubmarineManager(typeOfEnemyShip); } else { throw new ArgumentException("Nie dozwolona wartosc dla parametru", "typeOfEnemyShip"); } ShipOwner.AddShipTile(this); }