Exemplo n.º 1
0
        private void fi_BumpIntoShip(CShipEntity _otherShip)
        {
            CPlayer player      = CGameController.Get.mu_PlayerDict[mu_deviceId];
            CPlayer otherPlayer = CGameController.Get.mu_PlayerDict[_otherShip.mu_deviceId];

            player.pu_healthAmount      -= 1;
            otherPlayer.pu_healthAmount -= 1;
        }
Exemplo n.º 2
0
 private void fi_TryShootEnemyShip(int _xStep, int _yStep, int _maxSteps)
 {
     for (int mul = 0; mul < _maxSteps; mul++)
     {
         List <AOceanEntity> list = CGameController.Get.mu_ocean.fu_GetListAt(pu_x + _xStep * mul, pu_y + _yStep * mul);
         if (list.Count > 0)
         {
             if (list[0].pu_EntityType == EOceanEntityType.Ship)
             {
                 CShipEntity otherShip   = (CShipEntity)list[0];
                 CPlayer     otherPlayer = CGameController.Get.mu_PlayerDict[otherShip.mu_deviceId];
                 otherPlayer.pu_healthAmount -= 1;
             }
             break;
         }
     }
 }
Exemplo n.º 3
0
        public void fu_CreateOcean(int _numRocks, int _numSwirls, int _numStreams)
        {
            // first, distribute some rocks
            UnityEngine.Random.InitState((int)System.DateTime.Now.Ticks);
            AOceanEntity entity = null;
            int          x;
            int          y;

            // make rocks
            for (int i = 0; i < _numRocks; i++)
            {
                do
                {
                    x = UnityEngine.Random.Range((int)0, (int)mu_xSize);
                    y = UnityEngine.Random.Range((int)0, (int)mu_ySize);
                } while (fu_IsPlaceOccupied(x, y));
                entity = new CRockEntity(x, y, EOrientation.North);
                mi_entityList.Add(entity);
            }

            // make ships
            foreach (var kvp in CGameController.Get.mu_PlayerDict)
            {
                Debug.Log("Creating Ship!");

                do
                {
                    x = UnityEngine.Random.Range((int)0, (int)mu_xSize);
                    y = UnityEngine.Random.Range((int)0, (int)mu_ySize);
                } while (fu_IsPlaceOccupied(x, y));

                EOrientation or = (EOrientation)UnityEngine.Random.Range(0, (int)EOrientation.MAX_ORIENTATION);

                int deviceId = kvp.Key;
                entity = new CShipEntity(x, y, or, deviceId);
                mi_entityList.Add(entity);

                Debug.Log("Ship " + entity.ToString() + " created!");
            }

            // make swirls
            for (int i = 0; i < _numSwirls; i++)
            {
                do
                {
                    x = UnityEngine.Random.Range((int)0, (int)mu_xSize);
                    y = UnityEngine.Random.Range((int)0, (int)mu_ySize);
                } while (fi_IsPlaceOccupiedForSwirl(x, y));

                // top row
                entity = new CSwirlClockEntity(x - 1, y - 1, EOrientation.East);
                mi_entityList.Add(entity);
                entity = new CStreamEntity(x, y - 1, EOrientation.East);
                mi_entityList.Add(entity);
                entity = new CSwirlClockEntity(x + 1, y - 1, EOrientation.South);
                mi_entityList.Add(entity);

                // center row
                entity = new CStreamEntity(x - 1, y, EOrientation.North);
                mi_entityList.Add(entity);
                entity = new CSwirlCenterEntity(x, y, EOrientation.MAX_ORIENTATION);
                mi_entityList.Add(entity);
                entity = new CStreamEntity(x + 1, y, EOrientation.South);
                mi_entityList.Add(entity);

                // bottom row
                entity = new CSwirlClockEntity(x - 1, y + 1, EOrientation.North);
                mi_entityList.Add(entity);
                entity = new CStreamEntity(x, y + 1, EOrientation.West);
                mi_entityList.Add(entity);
                entity = new CSwirlClockEntity(x + 1, y + 1, EOrientation.West);
                mi_entityList.Add(entity);
            }

            // make streams
            for (int i = 0; i < _numStreams; i++)
            {
                do
                {
                    x = UnityEngine.Random.Range((int)0, (int)mu_xSize);
                    y = UnityEngine.Random.Range((int)0, (int)mu_ySize);
                } while (fu_IsPlaceOccupied(x, y));

                EOrientation or = (EOrientation)UnityEngine.Random.Range(0, (int)EOrientation.MAX_ORIENTATION);
                entity = new CRockEntity(x, y, or);
                mi_entityList.Add(entity);
            }
        }