Ejemplo n.º 1
0
    public void DestroyFleet(Fleet fleet)
    {
        var tileOfFleet = TileList.Find(t => t.Fleet == fleet);

        tileOfFleet.Fleet = null;

        Destroy(fleet.FleetParent.gameObject);

        TileManager.ResetHighlightedTile();

        FleetList.Remove(fleet);
    }
Ejemplo n.º 2
0
    private void AddUnitsToFleetIfFleetExists()
    {
        for (int i = 0; i < BufferedUnitList.Count; i++)
        {
            var tile = TileList.Find(t => t.Position == BufferedUnitList[i].FleetPosition);

            if (tile == null)
            {
                return;
            }

            var fleet = tile.Fleet;

            AddBufferedUnitsToFleet(fleet, BufferedUnitList[i]);
        }
    }
Ejemplo n.º 3
0
    private void NetworkMoveFleet(int fleetID, Vector2 targetTilePosition)
    {
        var fleet = FleetList.Find(f => f.ID == fleetID);

        if (fleet == null)
        {
            return;
        }

        var currentTile = TileList.Find(t => t.Fleet == fleet);
        var targetTile  = TileList.Find(t => t.Position == targetTilePosition);

        targetTile.Fleet  = fleet;
        currentTile.Fleet = null;

        fleet.MoveFleet(targetTile.TileParent.position);
    }
Ejemplo n.º 4
0
    public void AddBufferedFleetsToWorld(BufferedFleet bufferedFleet)
    {
        var fleetTile = TileList.Find(t => t.Position == bufferedFleet.Position);

        if (fleetTile.Fleet != null)
        {
            return;
        }

        var fleetParent = new GameObject("Fleet of: " + bufferedFleet.Player).transform;

        fleetParent.position = fleetTile.TileParent.position;
        fleetParent.SetParent(GameObject.Find(Tags.Fleets).transform);

        #region Instantiate units
        var units = new Unit[6];

        for (int i = 0; i < units.Length; i++)
        {
            var unitParent = new GameObject("Unit: " + i).transform;

            fleetParent.rotation = Quaternion.Euler(Vector3.up * (i * -60 - 30));

            unitParent.position = fleetTile.TileParent.position + Vector3.forward * 0.6f;
            unitParent.SetParent(fleetParent);
        }

        fleetParent.rotation = Quaternion.identity;
        #endregion

        var newFleet = new Fleet(bufferedFleet.ID, bufferedFleet.Player, fleetParent, (FleetType)bufferedFleet.FleetType, units);

        FleetList.Add(newFleet);

        fleetTile.Fleet = newFleet;

        BufferedFleetList.Remove(bufferedFleet);
    }