public virtual void Start()
        {
            _startTime = 0;

            if(Game.IsSinglePlayer())
                Island = GetComponent<IslandData>();
        }
Пример #2
0
        public static float DominancePercentage(IslandData island)
        {
            var friendly = 0;
            var foes     = 0;

            for (var i = 0; i < island.transform.childCount; ++i)
            {
                var ship          = island.transform.GetChild(i).gameObject;
                var otherShipData = ship.GetComponent <ShipData>(); // possibly cachable
                if (otherShipData == null)
                {
                    continue;                        // skip non ship gameobjects
                }
                if (otherShipData.PlayerData.uid == island.PlayerData.uid)
                {
                    ++friendly;
                }
                else
                {
                    ++foes;
                }
            }

            var sum = foes + friendly;

            return(sum == 0 ? 1f : friendly / (float)sum);
        }
        public void Start()
        {
			Registry.Islands.Add(Uid, this.gameObject);
            InitLineRender();
            Island = GetComponent<IslandData>();
            cameraMovement = Camera.main.GetComponent<MoveCamera>();
        }
Пример #4
0
        public static ArrayList GetEnemyShips(IslandData island, string thisUid)
        {
            var enemyShips = new ArrayList(island.transform.childCount - 1);

            for (var i = 0; i < island.transform.childCount; ++i)
            {
                var ship          = island.transform.GetChild(i).gameObject;
                var otherShipData = ship.GetComponent <ShipData>(); // possibly cachable
                if (otherShipData == null)
                {
                    continue;                        // skip non ship gameobjects
                }
                if (otherShipData.PlayerData.uid != thisUid)
                {
                    enemyShips.Add(ship);
                }
            }
            return(enemyShips);
        }
Пример #5
0
        public static int AmountFriendlyUnits(IslandData island)
        {
            var friendly = 0;

            for (var i = 0; i < island.transform.childCount; ++i)
            {
                var ship          = island.transform.GetChild(i).gameObject;
                var otherShipData = ship.GetComponent <ShipData>(); // possibly cachable
                if (otherShipData == null)
                {
                    continue;                        // skip non ship gameobjects
                }
                if (otherShipData.PlayerData.uid == island.PlayerData.uid)
                {
                    ++friendly;
                }
            }

            return(friendly);
        }
        public static float DominancePercentage(IslandData island)
        {
            var friendly = 0;
            var foes = 0;

            for (var i = 0; i < island.transform.childCount; ++i)
            {
                var ship = island.transform.GetChild(i).gameObject;
                var otherShipData = ship.GetComponent<ShipData>(); // possibly cachable
                if (otherShipData == null) continue; // skip non ship gameobjects
                if (otherShipData.PlayerData.uid == island.PlayerData.uid)
                {
                    ++friendly;
                }
                else
                {
                    ++foes;
                }
            }

            var sum = foes + friendly;

            return sum == 0 ? 1f : friendly/(float)sum;
        }
 public static ArrayList GetFriendlyShips(IslandData island, string thisUid)
 {
     var enemyShips = new ArrayList(island.transform.childCount - 1);
     for (var i = 0; i < island.transform.childCount; ++i)
     {
         var ship = island.transform.GetChild(i).gameObject;
         var otherShipData = ship.GetComponent<ShipData>(); // possibly cachable
         if (otherShipData == null) continue; // skip non ship gameobjects
         if (otherShipData.PlayerData.uid == thisUid)
             enemyShips.Add(ship);
     }
     return enemyShips;
 }
        public static int AmountFriendlyUnits(IslandData island)
        {
            var friendly = 0;

            for (var i = 0; i < island.transform.childCount; ++i)
            {
                var ship = island.transform.GetChild(i).gameObject;
                var otherShipData = ship.GetComponent<ShipData>(); // possibly cachable
                if (otherShipData == null) continue; // skip non ship gameobjects
                if (otherShipData.PlayerData.uid == island.PlayerData.uid)
                {
                    ++friendly;
                }
            }

            return friendly;
        }