Exemple #1
0
    public WallNode SetRandomWallNodePunchable(bool isLeft)
    {
        WallNode node = GetRandomInactiveWallNode();

        node.SetPunchable(isLeft);
        return(node);
    }
 void NodePunched(WallNode node)
 {
     node.OnNodePunched.RemoveListener(NodePunched);
     NodesPunched++;
     NumPunchableNodesRemaining--;
     if (NumPunchableNodesRemaining <= 0)
     {
         ActivatePunchableNodeWave();
     }
 }
    void ActivatePunchableNodeWave(int numNodes)
    {
        WallNodeManager randomWall = GetRandomWallNodeManager();

        for (int i = 0; i < numNodes; i++)
        {
            WallNode node = randomWall.SetRandomWallNodePunchable(_lastNodeLeft);
            node.OnNodePunched.AddListener(NodePunched);
            _lastNodeLeft = !_lastNodeLeft;
        }

        NumPunchableNodesRemaining = numNodes;
    }
Exemple #4
0
 public WallBrush() : base()
 {
     wall_items = new WallNode[17];
     door_items = new List <DoorType> [17];
     for (int x = 0; x < 17; x++)
     {
         door_items[x] = new List <DoorType>();
     }
     for (int x = 0; x < 17; x++)
     {
         wall_items[x] = new WallNode();
     }
 }
Exemple #5
0
    void gen_nodes_from_cmds()
    {
        all_nodes = new List <List <WallNode> >();
        foreach (List <Cmd> wall_cmds in all_wall_cmds)
        {
            List <WallNode> nodes  = new List <WallNode>();
            float           length = 0;
            wall_cmds.Add(wall_cmds[0]);             // nodes need to wrap around so that final segment doesn't have warped uvs
            foreach (Cmd cmd in wall_cmds)
            {
                int      x     = cmd.pos.x;
                int      y     = cmd.pos.y;
                WallNode endpt = null;
                WallNode midpt = new WallNode((x + 0.5f), (y + 0.5f), cell_size, length + (sqrt2 / 2f), depth, texture_scale);

                switch (cmd.dir)
                {
                case LEFT:
                    endpt = new WallNode((x + 0), (y + 1), cell_size, length, depth, texture_scale); break;

                case UP:
                    endpt = new WallNode((x + 0), (y + 0), cell_size, length, depth, texture_scale); break;

                case RIGHT:
                    endpt = new WallNode((x + 1), (y + 0), cell_size, length, depth, texture_scale); break;

                case DOWN:
                    endpt = new WallNode((x + 1), (y + 1), cell_size, length, depth, texture_scale); break;
                }
                switch (cmd.type)
                {
                case LINE:
                    length += cell_size; break;

                case CORNER:
                    length += cell_size * sqrt2; break;

                case ALLEY:
                    length += cell_size * sqrt2; break;
                }

                nodes.Add(endpt);
                if (cmd.type == ALLEY)
                {
                    nodes.Add(midpt);
                }
            }
            wall_cmds.RemoveAt(wall_cmds.Count - 1);             // remove the wrap-around command
            all_nodes.Add(nodes);
        }
    }
Exemple #6
0
    public void BuildWallOn(WallNode node)
    {
        if (PlayerStats.Money < wallToBuild.cost)
        {
            Debug.Log("Not enough money to build that");
            return;
        }

        PlayerStats.Money -= wallToBuild.cost;

        GameObject wall = (GameObject)Instantiate(wallToBuild.prefab, node.GetBuildPosition(), Quaternion.identity);

        node.wall = wall;

        Debug.Log("Wall Built! Money Remaining: " + PlayerStats.Money);
    }
        public WallUpgradeScreen(Entity selectedBuilding) : base(selectedBuilding)
        {
            this.useUpgradeGroup  = true;
            this.currentWallLevel = this.buildingInfo.Lvl;
            this.wallsOfSameLevel = new List <Entity>();
            string key = selectedBuilding.Get <BuildingComponent>().BuildingTO.Key;
            NodeList <WallNode> wallNodeList = Service.Get <BuildingLookupController>().WallNodeList;

            for (WallNode wallNode = wallNodeList.Head; wallNode != null; wallNode = wallNode.Next)
            {
                if (wallNode.BuildingComp.BuildingTO.Key != key && wallNode.BuildingComp.BuildingType.Lvl == this.currentWallLevel)
                {
                    this.wallsOfSameLevel.Add(wallNode.Entity);
                }
            }
            this.allWallSameLevelCount = this.wallsOfSameLevel.Count + 1;
        }
Exemple #8
0
        public override void draw(GameMap map, Tile tile, object param)
        {
            if (false)
            {
            }
            tile.cleanWalls(this);
            UInt16    id        = 0;
            WallBrush try_brush = this;

            while (true)
            {
                if (id != 0)
                {
                    break;
                }
                if (try_brush == null)
                {
                    return;
                }

                for (int i = 0; i < 16; ++i)
                {
                    WallNode wn = try_brush.wall_items[i];
                    if (wn.total_chance <= 0)
                    {
                        continue;
                    }
                    int chance = random.Next(1, wn.total_chance + 1);

                    foreach (WallType wt in wn.items)
                    {
                        if (chance <= wt.chance)
                        {
                            id = wt.id;
                            break;
                        }
                    }
                    if (id != 0)
                    {
                        break;
                    }
                }
            }
            tile.addWallItem(Item.Create(id));
        }
Exemple #9
0
    void create_wall_triangles(WallNode n0, WallNode n1)
    {
        int ind = vertices.Count;

        int[] indices = { ind + 0, ind + 1, ind + 2, ind + 3, ind + 4, ind + 5 };
        triangles.AddRange(indices);

        vertices.Add(n0.lower - offset);
        vertices.Add(n1.lower - offset);
        vertices.Add(n0.upper - offset);

        vertices.Add(n1.lower - offset);
        vertices.Add(n1.upper - offset);
        vertices.Add(n0.upper - offset);

        uvs.Add(n0.uv_lower);
        uvs.Add(n1.uv_lower);
        uvs.Add(n0.uv_upper);

        uvs.Add(n1.uv_lower);
        uvs.Add(n1.uv_upper);
        uvs.Add(n0.uv_upper);
    }
Exemple #10
0
    void SpawnWallNodes()
    {
        NumNodesHorizontal = Mathf.FloorToInt(_info.Width / NodeWidth);
        NumNodesVertical   = Mathf.FloorToInt(_info.Height / NodeHeight);

        WallNodes = new WallNode[NumNodesHorizontal, NumNodesVertical];

        float xRemainder = _info.Width - (NodeWidth * NumNodesHorizontal);
        float yRemainder = _info.Height - (NodeHeight * NumNodesVertical);

        float spacingX = xRemainder / (NumNodesHorizontal + 1);
        float spacingY = yRemainder / (NumNodesVertical + 1);

        //start at bottom left corner
        //transform.position is at the center of the wall
        float startX = -(_info.Width / 2);
        float startY = -(_info.Height / 2);

        startX += spacingX + (NodeWidth / 2);
        startY += spacingY + (NodeHeight / 2);

        for (int x = 0; x < NumNodesHorizontal; x++)
        {
            float curX = startX + (x * NodeWidth) + (x * spacingX);
            for (int y = 0; y < NumNodesVertical; y++)
            {
                float    curY    = startY + (y * NodeHeight) + (y * spacingY);
                WallNode newNode = Instantiate(NodePrefab);
                newNode.transform.rotation      = this.transform.rotation;
                newNode.transform.parent        = this.transform;
                newNode.transform.localPosition = new Vector3(curX, curY, 0);
                newNode.transform.localScale    = new Vector3(NodeWidth, NodeHeight, NodeWidth);
                WallNodes[x, y] = newNode;
            }
        }
    }
Exemple #11
0
        public int GetWallNodeIndex(WallNode wall)
        {
            Debug.Assert(wall != null);

            return(WallNodes.IndexOf(wall));
        }
Exemple #12
0
 void Start()
 {
     SearchList = new List <Wall>();
     y          = x - 1;
     NodeList   = new WallNode[x, x];
     WallListi  = new Wall[y, x];
     WallListj  = new Wall[x, y];
     for (int i = 0; i < x; i++)
     {
         for (int j = 0; j < x; j++)
         {
             Vector3  position = new Vector3(i, 0, j);
             WallNode node     = new WallNode();
             node.WallLsit  = new List <Wall>();
             node.Position  = position;
             NodeList[i, j] = node;
         }
     }
     for (int i = 0; i < y; i++)
     {
         for (int j = 0; j < x; j++)
         {
             GameObject Walli = Instantiate(Wall) as GameObject;
             Walli.transform.eulerAngles = new Vector3(0, 90, 0);
             Walli.transform.position    = NodeList[i, j].Position + new Vector3(0.5f, 0, 0);
             Walli.name               = ("i" + i + " " + j);
             WallListi[i, j]          = new Wall();
             WallListi[i, j].wall     = Walli;
             WallListi[i, j].NodeList = new List <WallNode>();
             WallListi[i, j].NodeList.Add(NodeList[i, j]);
             WallListi[i, j].NodeList.Add(NodeList[i + 1, j]);
         }
     }
     for (int i = 0; i < x; i++)
     {
         for (int j = 0; j < y; j++)
         {
             GameObject Wallj = Instantiate(Wall) as GameObject;
             Wallj.transform.position = NodeList[i, j].Position + new Vector3(0, 0, 0.5f);
             Wallj.name               = ("j" + i + " " + j);
             WallListj[i, j]          = new Wall();
             WallListj[i, j].wall     = Wallj;
             WallListj[i, j].NodeList = new List <WallNode>();
             WallListj[i, j].NodeList.Add(NodeList[i, j]);
             WallListj[i, j].NodeList.Add(NodeList[i, j + 1]);
         }
     }
     for (int i = 0; i < x; i++)
     {
         for (int j = 0; j < x; j++)
         {
             if (i != x - 1)
             {
                 NodeList[i, j].WallLsit.Add(WallListi[i, j]);
             }
             if (j != x - 1)
             {
                 NodeList[i, j].WallLsit.Add(WallListj[i, j]);
             }
             if (i != 0)
             {
                 NodeList[i, j].WallLsit.Add(WallListi[i - 1, j]);
             }
             if (j != 0)
             {
                 NodeList[i, j].WallLsit.Add(WallListj[i, j - 1]);
             }
             //Debug.Log(i + " " + j + " " + NodeList[i, j].WallLsit.Count);
         }
     }
     NodeList[1, 1].isConnect = true;
     for (int i = 0; i < NodeList[1, 1].WallLsit.Count; i++)
     {
         SearchList.Add(NodeList[1, 1].WallLsit[i]);
     }
     MigongCreate();
     for (int i = 0; i < x; i++)
     {
         GameObject WallStartic1 = Instantiate(Wall) as GameObject;
         GameObject WallStartic2 = Instantiate(Wall) as GameObject;
         WallStartic1.name = "WallStartic";
         WallStartic2.name = "WallStartic";
         WallStartic1.transform.position = NodeList[i, 0].Position + new Vector3(0, 0, -0.5f);
         WallStartic2.transform.position = NodeList[i, x - 1].Position + new Vector3(0, 0, 0.5f);
     }
     for (int i = 0; i < x; i++)
     {
         GameObject WallStartic1 = Instantiate(Wall) as GameObject;
         GameObject WallStartic2 = Instantiate(Wall) as GameObject;
         WallStartic1.transform.eulerAngles = new Vector3(0, 90, 0);
         WallStartic2.transform.eulerAngles = new Vector3(0, 90, 0);
         WallStartic1.name = "WallStartic";
         WallStartic2.name = "WallStartic";
         WallStartic1.transform.position = NodeList[0, i].Position + new Vector3(-0.5f, 0, 0);
         WallStartic2.transform.position = NodeList[x - 1, i].Position + new Vector3(0.5f, 0, 0);
     }
 }
 public LaserNodePair(WallNode n1, WallNode n2)
 {
     Node1 = n1;
     Node2 = n2;
 }
Exemple #14
0
        private void FillBuildingListByType(List <SmartEntity> list, BuildingType type)
        {
            switch (type)
            {
            case BuildingType.Any:
            {
                NodeList <BuildingNode> nodeList = this.entityController.GetNodeList <BuildingNode>();
                for (BuildingNode buildingNode = nodeList.Head; buildingNode != null; buildingNode = buildingNode.Next)
                {
                    list.Add((SmartEntity)buildingNode.Entity);
                }
                return;
            }

            case BuildingType.HQ:
                for (HQNode hQNode = this.HQNodeList.Head; hQNode != null; hQNode = hQNode.Next)
                {
                    list.Add((SmartEntity)hQNode.Entity);
                }
                return;

            case BuildingType.Barracks:
                for (BarracksNode barracksNode = this.BarracksNodeList.Head; barracksNode != null; barracksNode = barracksNode.Next)
                {
                    list.Add((SmartEntity)barracksNode.Entity);
                }
                return;

            case BuildingType.Factory:
                for (FactoryNode factoryNode = this.FactoryNodeList.Head; factoryNode != null; factoryNode = factoryNode.Next)
                {
                    list.Add((SmartEntity)factoryNode.Entity);
                }
                return;

            case BuildingType.FleetCommand:
                for (FleetCommandNode fleetCommandNode = this.FleetCommandNodeList.Head; fleetCommandNode != null; fleetCommandNode = fleetCommandNode.Next)
                {
                    list.Add((SmartEntity)fleetCommandNode.Entity);
                }
                return;

            case BuildingType.HeroMobilizer:
                for (TacticalCommandNode tacticalCommandNode = this.TacticalCommandNodeList.Head; tacticalCommandNode != null; tacticalCommandNode = tacticalCommandNode.Next)
                {
                    list.Add((SmartEntity)tacticalCommandNode.Entity);
                }
                return;

            case BuildingType.ChampionPlatform:
                for (ChampionPlatformNode championPlatformNode = this.ChampionPlatformNodeList.Head; championPlatformNode != null; championPlatformNode = championPlatformNode.Next)
                {
                    list.Add((SmartEntity)championPlatformNode.Entity);
                }
                return;

            case BuildingType.Housing:
                for (HousingNode housingNode = this.HousingNodeList.Head; housingNode != null; housingNode = housingNode.Next)
                {
                    list.Add((SmartEntity)housingNode.Entity);
                }
                return;

            case BuildingType.Squad:
                for (SquadBuildingNode squadBuildingNode = this.SquadBuildingNodeList.Head; squadBuildingNode != null; squadBuildingNode = squadBuildingNode.Next)
                {
                    list.Add((SmartEntity)squadBuildingNode.Entity);
                }
                return;

            case BuildingType.Starport:
                for (StarportNode starportNode = this.StarportNodeList.Head; starportNode != null; starportNode = starportNode.Next)
                {
                    list.Add((SmartEntity)starportNode.Entity);
                }
                return;

            case BuildingType.DroidHut:
                for (DroidHutNode droidHutNode = this.DroidHutNodeList.Head; droidHutNode != null; droidHutNode = droidHutNode.Next)
                {
                    list.Add((SmartEntity)droidHutNode.Entity);
                }
                return;

            case BuildingType.Wall:
                for (WallNode wallNode = this.WallNodeList.Head; wallNode != null; wallNode = wallNode.Next)
                {
                    list.Add((SmartEntity)wallNode.Entity);
                }
                return;

            case BuildingType.Turret:
                for (TurretBuildingNode turretBuildingNode = this.TurretBuildingNodeList.Head; turretBuildingNode != null; turretBuildingNode = turretBuildingNode.Next)
                {
                    list.Add((SmartEntity)turretBuildingNode.Entity);
                }
                return;

            case BuildingType.TroopResearch:
                for (OffenseLabNode offenseLabNode = this.OffenseLabNodeList.Head; offenseLabNode != null; offenseLabNode = offenseLabNode.Next)
                {
                    list.Add((SmartEntity)offenseLabNode.Entity);
                }
                return;

            case BuildingType.DefenseResearch:
                for (DefenseLabNode defenseLabNode = this.DefenseLabNodeList.Head; defenseLabNode != null; defenseLabNode = defenseLabNode.Next)
                {
                    list.Add((SmartEntity)defenseLabNode.Entity);
                }
                return;

            case BuildingType.Resource:
                for (GeneratorNode generatorNode = this.GeneratorNodeList.Head; generatorNode != null; generatorNode = generatorNode.Next)
                {
                    list.Add((SmartEntity)generatorNode.Entity);
                }
                return;

            case BuildingType.Storage:
                for (StorageNode storageNode = this.StorageNodeList.Head; storageNode != null; storageNode = storageNode.Next)
                {
                    list.Add((SmartEntity)storageNode.Entity);
                }
                return;

            case BuildingType.ShieldGenerator:
                for (ShieldGeneratorNode shieldGeneratorNode = this.ShieldGeneratorNodeList.Head; shieldGeneratorNode != null; shieldGeneratorNode = shieldGeneratorNode.Next)
                {
                    list.Add((SmartEntity)shieldGeneratorNode.Entity);
                }
                return;

            case BuildingType.Clearable:
                for (ClearableNode clearableNode = this.ClearableNodeList.Head; clearableNode != null; clearableNode = clearableNode.Next)
                {
                    list.Add((SmartEntity)clearableNode.Entity);
                }
                return;

            case BuildingType.Trap:
                for (TrapNode trapNode = this.TrapNodeList.Head; trapNode != null; trapNode = trapNode.Next)
                {
                    list.Add((SmartEntity)trapNode.Entity);
                }
                return;

            case BuildingType.Cantina:
                for (CantinaNode cantinaNode = this.CantinaNodeList.Head; cantinaNode != null; cantinaNode = cantinaNode.Next)
                {
                    list.Add((SmartEntity)cantinaNode.Entity);
                }
                return;

            case BuildingType.NavigationCenter:
                for (NavigationCenterNode navigationCenterNode = this.NavigationCenterNodeList.Head; navigationCenterNode != null; navigationCenterNode = navigationCenterNode.Next)
                {
                    list.Add((SmartEntity)navigationCenterNode.Entity);
                }
                return;

            case BuildingType.ScoutTower:
                for (ScoutTowerNode scoutTowerNode = this.ScoutTowerNodeList.Head; scoutTowerNode != null; scoutTowerNode = scoutTowerNode.Next)
                {
                    list.Add((SmartEntity)scoutTowerNode.Entity);
                }
                return;

            case BuildingType.Armory:
                for (ArmoryNode armoryNode = this.ArmoryNodeList.Head; armoryNode != null; armoryNode = armoryNode.Next)
                {
                    list.Add((SmartEntity)armoryNode.Entity);
                }
                return;
            }
            Service.Logger.Warn("Unknown building type " + type);
        }
Exemple #15
0
        public static void doWalls(GameMap map, Tile tile)
        {
            int x = tile.Position.X;
            int y = tile.Position.Y;
            int z = tile.Position.Z;

            List <Item> items_to_add   = new List <Item>();
            List <Item> items_to_erase = new List <Item>();

            foreach (Item wall in tile.Items)
            {
                if (!wall.Type.IsWall)
                {
                    continue;
                }
                WallBrush wall_brush = wall.getWallBrush();
                if (wall_brush == null)
                {
                    continue;
                }


                if (wall_brush as WallDecorationBrush != null)
                {
                    items_to_add.Add(wall);
                    continue;
                }


                bool[] neighbours = new bool[4];
                if (x == 0)
                {
                    if (y == 0)
                    {
                        neighbours[0] = false;
                        neighbours[1] = false;
                        neighbours[2] = hasMatchingWallBrushAtTile(map, wall_brush, x + 1, y, z);
                        neighbours[3] = hasMatchingWallBrushAtTile(map, wall_brush, x, y + 1, z);
                    }
                    else
                    {
                        neighbours[0] = hasMatchingWallBrushAtTile(map, wall_brush, x, y - 1, z);
                        neighbours[1] = false;
                        neighbours[2] = hasMatchingWallBrushAtTile(map, wall_brush, x + 1, y, z);
                        neighbours[3] = hasMatchingWallBrushAtTile(map, wall_brush, x, y + 1, z);
                    }
                }
                else if (y == 0)
                {
                    neighbours[0] = false;
                    neighbours[1] = hasMatchingWallBrushAtTile(map, wall_brush, x - 1, y, z);
                    neighbours[2] = hasMatchingWallBrushAtTile(map, wall_brush, x + 1, y, z);
                    neighbours[3] = hasMatchingWallBrushAtTile(map, wall_brush, x, y + 1, z);
                }
                else
                {
                    neighbours[0] = hasMatchingWallBrushAtTile(map, wall_brush, x, y - 1, z);
                    neighbours[1] = hasMatchingWallBrushAtTile(map, wall_brush, x - 1, y, z);
                    neighbours[2] = hasMatchingWallBrushAtTile(map, wall_brush, x + 1, y, z);
                    neighbours[3] = hasMatchingWallBrushAtTile(map, wall_brush, x, y + 1, z);
                }
                UInt32 tiledata = 0;
                for (int i = 0; i < 4; i++)
                {
                    if (neighbours[i])
                    {
                        tiledata |= (UInt32)1 << i;
                    }
                }
                bool exit = false;
                for (int i = 0; i < 2; ++i)
                {
                    if (exit)
                    {
                        break;
                    }

                    int bt;
                    if (i == 0)
                    {
                        bt = Border_Types.full_border_types[tiledata];
                    }
                    else
                    {
                        bt = Border_Types.half_border_types[tiledata];
                    }
                    if (wall.getWallAlignment() == BorderType.WALL_UNTOUCHABLE)
                    {
                        items_to_add.Add(wall);
                        // items_to_remove.Add(wall);
                        exit = true;
                    }
                    else if (wall.getWallAlignment() == bt)
                    {
                        items_to_add.Add(wall);
                        //it = tile->items.erase(it);
                        exit = true;
                        //while(it != tile->items.end()) {
                        //  todo
                        // }
                    }
                    else
                    {
                        UInt16    id        = 0;
                        WallBrush try_brush = wall_brush;

                        while (true)
                        {
                            if (try_brush == null)
                            {
                                break;
                            }
                            if (id != 0)
                            {
                                break;
                            }

                            WallNode wn = try_brush.wall_items[(int)bt];
                            if (wn.total_chance <= 0)
                            {
                                if (wn.items.Count() == 0)
                                {
                                    try_brush = try_brush.redirect_to;
                                    if (try_brush == wall_brush)
                                    {
                                        break;                                                     // To prevent infinite loop
                                    }
                                    continue;
                                }
                                else
                                {
                                    id = wn.items[0].id;
                                }
                            }
                            else
                            {
                                int chance = random.Next(1, wn.total_chance + 1);
                                foreach (WallType node_iter in wn.items)
                                {
                                    if (chance <= node_iter.chance)
                                    {
                                        id = node_iter.id;
                                        break;
                                    }
                                }
                            }
                            // Propagate down the chain
                            try_brush = try_brush.redirect_to;
                            if (try_brush == wall_brush)
                            {
                                break;                                             // To prevent infinite loop
                            }
                        }
                        if (try_brush == null && id == 0)
                        {
                            if (i == 1)
                            {
                                //++it;
                            }
                            continue;
                        }
                        else
                        {
                            // If there is such an item, add it to the tile
                            Item new_wall = Item.Create(id);
                            if (wall.isSelected())
                            {
//						        new_wall.isSelected = true;
                            }
                            items_to_add.Add(new_wall);
                            exit = true;
                            //++it;
                        }
                    }
                }
            }
            tile.cleanWalls(null);
            foreach (Item item in items_to_add)
            {
                tile.addWallItem(item);
            }
        }
Exemple #16
0
    void Start()
    {
        x = this.readJson.curDialogInfo.getWidth();
        s = this.readJson.curDialogInfo.getHeight();
        List <string> imgList = this.readJson.curDialogInfo.getImageList();

        foreach (string img in imgList)
        {
            textureList.Add((Texture2D)Resources.Load(img));
        }
//		Wall.GetComponent<Renderer> ().material.mainTexture = texture;
        space      = Wall.transform.localScale.z / 2f;
        wallLength = Wall.transform.localScale.z;
        wallHight  = Wall.transform.localScale.y;
        Ground.transform.localScale = new Vector3(s * wallLength, 1, x * wallLength);
        Ground.transform.position   = new Vector3(s * wallLength / 2f - wallLength / 2f, 0f, x * wallLength / 2f - wallLength / 2f);
        float doorX = s * wallLength - Door.transform.localScale.x - wallLength / 2f + Door.transform.localScale.x / 2f;
        float doorZ = x * wallLength - Door.transform.localScale.z - wallLength / 2f + Door.transform.localScale.z / 2f;

        Door.transform.position = new Vector3(doorX, Door.transform.position.y, doorZ);
//		Ground.transform.localScale.z = s * wallLength;
        SearchList = new List <Wall> ();
        NodeList   = new WallNode[s, x];
        WallListi  = new Wall[s, x];
        WallListj  = new Wall[x, s];
        for (int i = 0; i < s; i++)
        {
            for (int j = 0; j < x; j++)
            {
                Vector3  position = new Vector3(i * wallLength, 0, j * wallLength);
                WallNode node     = new WallNode();
                node.WallLsit   = new List <Wall> ();
                node.Position   = position;
                NodeList [i, j] = node;
            }
        }
        for (int i = 0; i < s - 1; i++)
        {
            for (int j = 0; j < x; j++)
            {
                GameObject Walli = Instantiate(Wall) as GameObject;
                this.setTexture(Walli);
//				Walli.GetComponent<Renderer> ().material.mainTexture = textureList [Random.Range (0, textureList.Count)];
//				Walli.transform.eulerAngles = new Vector3 (0, 90, 0);
                Walli.transform.position = NodeList [i, j].Position + new Vector3(space, wallHight / 2, 0);
                Walli.name                = ("i" + i + " " + j);
                WallListi [i, j]          = new Wall();
                WallListi [i, j].wall     = Walli;
                WallListi [i, j].NodeList = new List <WallNode> ();
                WallListi [i, j].NodeList.Add(NodeList [i, j]);
                WallListi [i, j].NodeList.Add(NodeList [i + 1, j]);
            }
        }
        for (int i = 0; i < x - 1; i++)
        {
            for (int j = 0; j < s; j++)
            {
                GameObject Wallj = Instantiate(Wall) as GameObject;
                this.setTexture(Wallj);
//				Wallj.GetComponent<Renderer> ().material.mainTexture = textureList [Random.Range (0, textureList.Count)];
                Wallj.transform.eulerAngles = new Vector3(0, 90, 0);
                Wallj.transform.position    = NodeList [j, i].Position + new Vector3(0, wallHight / 2, space);
                Wallj.name                = ("j" + i + " " + j);
                WallListj [i, j]          = new Wall();
                WallListj [i, j].wall     = Wallj;
                WallListj [i, j].NodeList = new List <WallNode> ();
                WallListj [i, j].NodeList.Add(NodeList [j, i]);
                WallListj [i, j].NodeList.Add(NodeList [j, i + 1]);
            }
        }
        for (int i = 0; i < s; i++)
        {
            for (int j = 0; j < x; j++)
            {
                if (i != 0)
                {
                    NodeList [i, j].WallLsit.Add(WallListi [i - 1, j]);
                }
                if (j != 0)
                {
                    NodeList [i, j].WallLsit.Add(WallListj [j - 1, i]);
                }
                if (i != s - 1)
                {
                    NodeList [i, j].WallLsit.Add(WallListi [i, j]);
                }
                if (j != x - 1)
                {
                    NodeList [i, j].WallLsit.Add(WallListj [j, i]);
                }
            }
        }
        NodeList [1, 1].isConnect = true;
        for (int i = 0; i < NodeList [1, 1].WallLsit.Count; i++)
        {
            SearchList.Add(NodeList [1, 1].WallLsit [i]);
        }
        MigongCreate();
        for (int i = 0; i < s; i++)
        {
            GameObject WallStartic1 = Instantiate(Wall) as GameObject;
            GameObject WallStartic2 = Instantiate(Wall) as GameObject;
            this.setTexture(WallStartic1);
            this.setTexture(WallStartic2);
//			WallStartic1.GetComponent<Renderer> ().material.mainTexture = textureList [Random.Range (0, textureList.Count)];
//			WallStartic2.GetComponent<Renderer> ().material.mainTexture = textureList [Random.Range (0, textureList.Count)];
            WallStartic1.transform.eulerAngles = new Vector3(0, 90, 0);
            WallStartic2.transform.eulerAngles = new Vector3(0, 90, 0);
            WallStartic1.name = "WallStartic1";
            WallStartic2.name = "WallStartic1";
            WallStartic1.transform.position = NodeList [i, 0].Position + new Vector3(0, wallHight / 2, -space);
            WallStartic2.transform.position = NodeList [i, x - 1].Position + new Vector3(0, wallHight / 2, space);
        }
        for (int i = 0; i < x; i++)
        {
            GameObject WallStartic1 = Instantiate(Wall) as GameObject;
            GameObject WallStartic2 = Instantiate(Wall) as GameObject;
            this.setTexture(WallStartic1);
            this.setTexture(WallStartic2);
//			WallStartic1.GetComponent<Renderer> ().material.mainTexture = textureList [Random.Range (0, textureList.Count)];
//			WallStartic2.GetComponent<Renderer> ().material.mainTexture = textureList [Random.Range (0, textureList.Count)];
//			WallStartic1.transform.eulerAngles = new Vector3 (0, 90, 0);
//			WallStartic2.transform.eulerAngles = new Vector3 (0, 90, 0);
            WallStartic1.name = "WallStartic2";
            WallStartic2.name = "WallStartic2";
            WallStartic1.transform.position = NodeList [0, i].Position + new Vector3(-space, wallHight / 2, 0);
            WallStartic2.transform.position = NodeList [s - 1, i].Position + new Vector3(space, wallHight / 2, 0);
        }
    }
Exemple #17
0
        public bool HasConstructedBuilding(BuildingTypeVO reqBuilding)
        {
            int lvl = reqBuilding.Lvl;

            switch (reqBuilding.Type)
            {
            case BuildingType.HQ:
                for (HQNode hQNode = this.HQNodeList.Head; hQNode != null; hQNode = hQNode.Next)
                {
                    if (GameUtils.GetBuildingEffectiveLevel((SmartEntity)hQNode.BuildingComp.Entity) >= lvl)
                    {
                        return(true);
                    }
                }
                return(false);

            case BuildingType.Barracks:
                for (BarracksNode barracksNode = this.BarracksNodeList.Head; barracksNode != null; barracksNode = barracksNode.Next)
                {
                    if (GameUtils.GetBuildingEffectiveLevel((SmartEntity)barracksNode.BuildingComp.Entity) >= lvl)
                    {
                        return(true);
                    }
                }
                return(false);

            case BuildingType.Factory:
                for (FactoryNode factoryNode = this.FactoryNodeList.Head; factoryNode != null; factoryNode = factoryNode.Next)
                {
                    if (GameUtils.GetBuildingEffectiveLevel((SmartEntity)factoryNode.BuildingComp.Entity) >= lvl)
                    {
                        return(true);
                    }
                }
                return(false);

            case BuildingType.FleetCommand:
                for (FleetCommandNode fleetCommandNode = this.FleetCommandNodeList.Head; fleetCommandNode != null; fleetCommandNode = fleetCommandNode.Next)
                {
                    if (GameUtils.GetBuildingEffectiveLevel((SmartEntity)fleetCommandNode.BuildingComp.Entity) >= lvl)
                    {
                        return(true);
                    }
                }
                return(false);

            case BuildingType.HeroMobilizer:
                for (TacticalCommandNode tacticalCommandNode = this.TacticalCommandNodeList.Head; tacticalCommandNode != null; tacticalCommandNode = tacticalCommandNode.Next)
                {
                    if (GameUtils.GetBuildingEffectiveLevel((SmartEntity)tacticalCommandNode.BuildingComp.Entity) >= lvl)
                    {
                        return(true);
                    }
                }
                return(false);

            case BuildingType.ChampionPlatform:
                for (ChampionPlatformNode championPlatformNode = this.ChampionPlatformNodeList.Head; championPlatformNode != null; championPlatformNode = championPlatformNode.Next)
                {
                    if (GameUtils.GetBuildingEffectiveLevel((SmartEntity)championPlatformNode.BuildingComp.Entity) >= lvl)
                    {
                        return(true);
                    }
                }
                return(false);

            case BuildingType.Housing:
                for (HousingNode housingNode = this.HousingNodeList.Head; housingNode != null; housingNode = housingNode.Next)
                {
                    if (GameUtils.GetBuildingEffectiveLevel((SmartEntity)housingNode.BuildingComp.Entity) >= lvl)
                    {
                        return(true);
                    }
                }
                return(false);

            case BuildingType.Squad:
                for (SquadBuildingNode squadBuildingNode = this.SquadBuildingNodeList.Head; squadBuildingNode != null; squadBuildingNode = squadBuildingNode.Next)
                {
                    if (GameUtils.GetBuildingEffectiveLevel((SmartEntity)squadBuildingNode.BuildingComp.Entity) >= lvl)
                    {
                        return(true);
                    }
                }
                return(false);

            case BuildingType.Starport:
                for (StarportNode starportNode = this.StarportNodeList.Head; starportNode != null; starportNode = starportNode.Next)
                {
                    if (GameUtils.GetBuildingEffectiveLevel((SmartEntity)starportNode.BuildingComp.Entity) >= lvl)
                    {
                        return(true);
                    }
                }
                return(false);

            case BuildingType.DroidHut:
                for (DroidHutNode droidHutNode = this.DroidHutNodeList.Head; droidHutNode != null; droidHutNode = droidHutNode.Next)
                {
                    if (GameUtils.GetBuildingEffectiveLevel((SmartEntity)droidHutNode.BuildingComp.Entity) >= lvl)
                    {
                        return(true);
                    }
                }
                return(false);

            case BuildingType.Wall:
                for (WallNode wallNode = this.WallNodeList.Head; wallNode != null; wallNode = wallNode.Next)
                {
                    if (GameUtils.GetBuildingEffectiveLevel((SmartEntity)wallNode.BuildingComp.Entity) >= lvl)
                    {
                        return(true);
                    }
                }
                return(false);

            case BuildingType.Turret:
                for (TurretBuildingNode turretBuildingNode = this.TurretBuildingNodeList.Head; turretBuildingNode != null; turretBuildingNode = turretBuildingNode.Next)
                {
                    if (turretBuildingNode.BuildingComp.BuildingType.UpgradeGroup == reqBuilding.UpgradeGroup && GameUtils.GetBuildingEffectiveLevel((SmartEntity)turretBuildingNode.BuildingComp.Entity) >= lvl)
                    {
                        return(true);
                    }
                }
                return(false);

            case BuildingType.TroopResearch:
                for (OffenseLabNode offenseLabNode = this.OffenseLabNodeList.Head; offenseLabNode != null; offenseLabNode = offenseLabNode.Next)
                {
                    if (GameUtils.GetBuildingEffectiveLevel((SmartEntity)offenseLabNode.BuildingComp.Entity) >= lvl)
                    {
                        return(true);
                    }
                }
                return(false);

            case BuildingType.DefenseResearch:
                for (DefenseLabNode defenseLabNode = this.DefenseLabNodeList.Head; defenseLabNode != null; defenseLabNode = defenseLabNode.Next)
                {
                    if (GameUtils.GetBuildingEffectiveLevel((SmartEntity)defenseLabNode.BuildingComp.Entity) >= lvl)
                    {
                        return(true);
                    }
                }
                return(false);

            case BuildingType.Resource:
                for (GeneratorNode generatorNode = this.GeneratorNodeList.Head; generatorNode != null; generatorNode = generatorNode.Next)
                {
                    if (generatorNode.BuildingComp.BuildingType.Currency == reqBuilding.Currency && GameUtils.GetBuildingEffectiveLevel((SmartEntity)generatorNode.BuildingComp.Entity) >= lvl)
                    {
                        return(true);
                    }
                }
                return(false);

            case BuildingType.Storage:
                for (StorageNode storageNode = this.StorageNodeList.Head; storageNode != null; storageNode = storageNode.Next)
                {
                    if (storageNode.BuildingComp.BuildingType.Currency == reqBuilding.Currency && GameUtils.GetBuildingEffectiveLevel((SmartEntity)storageNode.BuildingComp.Entity) >= lvl)
                    {
                        return(true);
                    }
                }
                return(false);

            case BuildingType.Trap:
                for (TrapNode trapNode = this.TrapNodeList.Head; trapNode != null; trapNode = trapNode.Next)
                {
                    if (GameUtils.GetBuildingEffectiveLevel((SmartEntity)trapNode.BuildingComp.Entity) >= lvl)
                    {
                        return(true);
                    }
                }
                return(false);

            case BuildingType.Cantina:
                for (CantinaNode cantinaNode = this.CantinaNodeList.Head; cantinaNode != null; cantinaNode = cantinaNode.Next)
                {
                    if (GameUtils.GetBuildingEffectiveLevel((SmartEntity)cantinaNode.BuildingComp.Entity) >= lvl)
                    {
                        return(true);
                    }
                }
                return(false);

            case BuildingType.NavigationCenter:
                for (NavigationCenterNode navigationCenterNode = this.NavigationCenterNodeList.Head; navigationCenterNode != null; navigationCenterNode = navigationCenterNode.Next)
                {
                    if (GameUtils.GetBuildingEffectiveLevel((SmartEntity)navigationCenterNode.BuildingComp.Entity) >= lvl)
                    {
                        return(true);
                    }
                }
                return(false);

            case BuildingType.ScoutTower:
                for (ScoutTowerNode scoutTowerNode = this.ScoutTowerNodeList.Head; scoutTowerNode != null; scoutTowerNode = scoutTowerNode.Next)
                {
                    if (GameUtils.GetBuildingEffectiveLevel((SmartEntity)scoutTowerNode.BuildingComp.Entity) >= lvl)
                    {
                        return(true);
                    }
                }
                return(false);

            case BuildingType.Armory:
                for (ArmoryNode armoryNode = this.ArmoryNodeList.Head; armoryNode != null; armoryNode = armoryNode.Next)
                {
                    if (GameUtils.GetBuildingEffectiveLevel((SmartEntity)armoryNode.BuildingComp.Entity) >= lvl)
                    {
                        return(true);
                    }
                }
                return(false);
            }
            Service.Logger.Warn("Unknown reqBuilding type for level: " + reqBuilding.Uid);
            return(false);
        }