コード例 #1
0
ファイル: Player_Board.cs プロジェクト: SojuJuseyo/Aliens-TD
    void createBoard(int x, int z, int dimx, int dimz, e_player player)
    {
        Vector3 tmpPos;
        bool isSlot;
        int id = 0;

        dimx += 2;
        dimz += 2;
        tmpPos.y = 0;
        tmpPos.x = 0;
        tmpPos.z = 0;
        for (int dim1 = 0; dim1 < dimx; ++dim1) {
            for (int dim2 = 0; dim2 < dimz; ++dim2){
                GameObject objectSlot = new GameObject();
                tmpPos.x = x + dim1;
                tmpPos.z = z + dim2;
                tmpPos.y = 0f;
                if (dim1 == 0 || dim2 == 0 || dim1 == dimx - 1 || dim2 == dimz - 1){
                    if (dim2 == dimz - 1 && dim1 == (dimx - 1) / 2){
                        if (playerIdentity.playerTeam == player){
                            mobSpawnCubeEnemy = Instantiate(mobSpawnCubeEnemy, tmpPos, Quaternion.identity) as GameObject;
                            mobSpawnCubeEnemy.transform.name = player.ToString() + "-MOBSPAWN";
                        }
                        else{
                            mobSpawnCubeAllied = Instantiate(mobSpawnCubeAllied, tmpPos, Quaternion.identity) as GameObject;
                            mobSpawnCubeAllied.transform.name = player.ToString() + "-MOBSPAWN";
                        }
                    }
                    else if (dim2 == 0 && dim1 == (dimx - 1) / 2){
                        objectSlot = Instantiate(borderNexus, tmpPos, Quaternion.identity) as GameObject;
                        objectSlot.transform.name = player.ToString() + "-NEXUS";
                    }
                    else{
                        if (playerIdentity.playerTeam == player)
                            objectSlot = Instantiate(borderObjectAllied, tmpPos, Quaternion.identity) as GameObject;
                        else
                            objectSlot = Instantiate(borderObjectEnemy, tmpPos, Quaternion.identity) as GameObject;
                        objectSlot.transform.name = player.ToString() + "-Border";

                    }
                    isSlot = false;
                }
                else{
                    objectSlot = Instantiate(slotObject, tmpPos, Quaternion.identity) as GameObject;
                    isSlot = true;
                }
                if (isSlot){
                    t_infoSlot newInfosSLot = new t_infoSlot();
                    newInfosSLot.player = player;
                    newInfosSLot.x = tmpPos.x;
                    newInfosSLot.z =  tmpPos.z;
                    newInfosSLot.tower = e_tower.NONE;
                    newInfosSLot.color = e_color.NONE;
                    newInfosSLot.level = 0;
                    newInfosSLot.name = player.ToString() + "-" + id.ToString();
                    newInfosSLot.id = id;
                    newInfosSLot.refTower = null;
                    objectSlot.GetComponent<FocusingSlot>().setInfos(newInfosSLot);
                    if (playerIdentity.playerTeam != player)
                        objectSlot.GetComponent<FocusingSlot>().enableSlot(false);
                    objectSlot.transform.name = newInfosSLot.name;
                    id++;
                }
            }
        }
    }