예제 #1
0
    public void RespawnBot(BotSides botSide)
    {
        IEntity botEntity = TankPoolManager.Instance.Get(botSpawnPoints[(int)botSide]);

        CorrectData(botEntity, (botSide == BotSides.TOP_LEFT || botSide == BotSides.TOP_RIGHT ? Teams.TOP : Teams.BOTTOM), TankTypes.BOT, BOT_TAG);
        SpawnBotCoroutine(botEntity, botSide);

        AudioManager.Instance.RequestSound(GameSounds.BOT_CREATED);
    }
예제 #2
0
 [MethodImpl(MethodImplOptions.AggressiveInlining)] public void SetBotSpawnPoint(BotSides botSide, Vector3 position)
 {
     botSpawnPoints[(int)botSide] = position;
     botSpawnPointObjects[(int)botSide].transform.position = botSpawnPoints[(int)botSide];
 }
예제 #3
0
    public void CreateMap(int mapID)
    {
        fixed(char *fixedPtr = maps[mapID].text)
        {
            char *ptr = fixedPtr;

            // To make sure i selected the right(Blue/Red Flag, Top/Bottom Player...)
            BotSides botStack    = BotSides.TOP_LEFT;
            Teams    playerStack = Teams.TOP;
            Teams    flagStack   = Teams.TOP;

            //

            for (int i = 0, j = 0; i < MAP_HEIGHT; i++)
            {
                while (*ptr != Char_To_Avoid && j < MAP_WIDTH)
                {
                    MapCodes tempCode = (MapCodes)(*ptr & 0b1111);                     // 0b1111 - This is a bit mask that allows you to convert digit chars to the real digits
                    switch (tempCode)
                    {
                    case MapCodes.EMPTY:
                        ptr++;
                        j++;
                        break;

                    case MapCodes.FLAG:
                        if (i == 0 || (MapCodes)(*(ptr - Salted_Map_Width) & 0b1111) != MapCodes.FLAG)                                   // Check upper code to avoid duplication of Flag
                        {
                            CorrectBlockBehaviour(BlockPoolManager.Instance.Get(Get2x2BlockPosition(MapTopLeftCorner, j, i), Quaternion_Identity), BlockTypes.FLAG, flagStack++);
                        }
                        ptr += 2;                                 // Skip because of (2x2) block size
                        j   += 2;
                        break;

                    case MapCodes.PLAYER:
                        if (i == 0 || (MapCodes)(*(ptr - Salted_Map_Width) & 0b1111) != MapCodes.PLAYER)                                   // Check upper code to avoid duplication of Player spawn point
                        {
                            SpawnManager.Instance.SetPlayerSpawnPoint(playerStack++, Get2x2BlockPosition(MapTopLeftCorner, j, i));
                        }
                        ptr += 2;                                 // Skip because of (2x2) block size
                        j   += 2;
                        break;

                    case MapCodes.BOT:
                        if (i == 0 || (MapCodes)(*(ptr - Salted_Map_Width) & 0b1111) != MapCodes.BOT)                                   // Check upper code to avoid duplication of Bot spawn point
                        {
                            SpawnManager.Instance.SetBotSpawnPoint(botStack++, Get2x2BlockPosition(MapTopLeftCorner, j, i));
                        }
                        ptr += 2;                                 // Skip because of (2x2) block size
                        j   += 2;
                        break;

                    default:
                        BlockTypes tempType = (BlockTypes)(tempCode - 1);                                                                                           // Minus one because of the empty block
                        CorrectBlockBehaviour(BlockPoolManager.Instance.Get(GetBlockPosition(MapTopLeftCorner, j, i), Quaternion_Identity), tempType, Teams.COUNT); // I set Teams.COUNT(It doesn't matter actually) because neither block has no team, except for flags
                        ptr++;
                        j++;
                        break;
                    }
                }
                ptr += New_Line_Length;                 // Skip new line chars
                j    = 0;
            }
        }

        Vector3 GetBlockPosition(Vector3 rootPos, int XPoint, int YPoint)
        {
            BufferVector.x = FULL_BLOCK_STEP * XPoint;
            BufferVector.y = -FULL_BLOCK_STEP * YPoint;
            return(rootPos + BufferVector);
        }

        Vector3 Get2x2BlockPosition(Vector3 rootPos, int XPoint, int YPoint)
        {
            BufferVector.x = FULL_BLOCK_STEP * XPoint;
            BufferVector.y = -FULL_BLOCK_STEP * YPoint;
            return(rootPos + BufferVector + Half_Block_Vector);
        }
    }