Ejemplo n.º 1
0
 public void StormMovesShips()
 {
     foreach (Unit u in GetPlayerUnits(currentPlayerSide))
     {
         int[]  xy          = GetXYbyTileName(u.gameObject.transform.parent.name);
         int    x           = xy[0];
         int    y           = xy[1];
         int[]  windDir     = currentWeather.curWind;
         MyTile tileToDrift = null;
         for (int radius = u.stormDrift; radius > 0; radius--)
         {
             tileToDrift = GetTileByXY(x + radius * windDir[0], y + (-1) * radius * windDir[0]).GetComponent <MyTile>();
             if (tileToDrift != null)
             {
                 break;
             }
         }
         if (tileToDrift == null)
         {
             tileToDrift = GetTileByXY(x, y).GetComponent <MyTile>();
         }
         u.transform.parent        = tileToDrift.gameObject.transform;
         u.transform.localPosition = new Vector2(0, 0);
         tileToDrift.AddShipToTile(u.gameObject);
         u.movementCompleted = true;
         ResetMoveHighlight();
         ResetUnderFireHighlight();
         if (!u.fireCompleted)
         {
             HighlightArea(tileToDrift.gameObject, "fire");
         }
     }
 }
Ejemplo n.º 2
0
    void AddShip(MyTile t, string name, string ship_class, Player player)
    {
        GameObject shipObj = Resources.Load("Prefabs/ship") as GameObject;
        GameObject s       = Instantiate(shipObj, new Vector3(0, 0, 0), Quaternion.identity);

        s.name = "ship";
        t.AddShipToTile(s);
        s.GetComponent <Unit>().SetupShip(ship_class, player.side, name);

        ships.Add(s);
    }