Exemplo n.º 1
0
 private void AddAllLoweredFootprints()
 {
     if (this.loweredFootprint == null)
     {
         this.loweredFootprint = new Footprint("Lowered Footprint", 3f);
         BuildingController      buildingController = Service.Get <BuildingController>();
         NodeList <BuildingNode> nodeList           = Service.Get <EntityController>().GetNodeList <BuildingNode>();
         for (BuildingNode buildingNode = nodeList.Head; buildingNode != null; buildingNode = buildingNode.Next)
         {
             SmartEntity smartEntity = (SmartEntity)buildingNode.Entity;
             if (!buildingController.IsLifted(smartEntity) && !Service.Get <BaseLayoutToolController>().IsBuildingStashed(smartEntity))
             {
                 this.AddLoweredFootprint(smartEntity);
             }
         }
         if (buildingController.IsPurchasing && !buildingController.IsLifted(buildingController.PurchasingBuilding))
         {
             this.AddLoweredFootprint((SmartEntity)buildingController.PurchasingBuilding);
         }
         bool allowErrorThrown = true;
         if (Service.Get <BaseLayoutToolController>().IsBaseLayoutModeActive)
         {
             allowErrorThrown = false;
         }
         this.loweredFootprint.GenerateMesh(true, false, allowErrorThrown);
     }
 }
Exemplo n.º 2
0
        public override void Execute()
        {
            base.Execute();
            Entity entity = null;
            NodeList <BuildingNode> nodeList = Service.Get <EntityController>().GetNodeList <BuildingNode>();

            for (BuildingNode buildingNode = nodeList.Head; buildingNode != null; buildingNode = buildingNode.Next)
            {
                if (buildingNode.BuildingComp.BuildingType.BuildingID.Equals(this.prepareArgs[0], 5))
                {
                    entity             = buildingNode.Entity;
                    this.buildingFound = true;
                    break;
                }
            }
            if (entity != null)
            {
                this.width  = Units.GridToBoardX(entity.Get <BuildingComponent>().BuildingType.SizeX);
                this.depth  = Units.GridToBoardZ(entity.Get <BuildingComponent>().BuildingType.SizeY);
                this.boardX = entity.Get <BoardItemComponent>().BoardItem.BoardX + this.width / 2;
                this.boardZ = entity.Get <BoardItemComponent>().BoardItem.BoardZ + this.depth / 2;
            }
            if (this.buildingFound)
            {
                Service.Get <BuildingController>().HighlightBuilding(entity);
                Service.Get <UXController>().MiscElementsManager.HighlightRegion((float)this.boardX, (float)this.boardZ, this.width, this.depth);
                Vector3 zero = Vector3.zero;
                zero.x = Units.BoardToWorldX(this.boardX);
                zero.z = Units.BoardToWorldZ(this.boardZ);
                Service.Get <WorldInitializer>().View.PanToLocation(zero);
                Service.Get <UserInputInhibitor>().AllowOnly(entity);
            }
            this.parent.ChildComplete(this);
        }
Exemplo n.º 3
0
        public static bool InstantFreeupDroid()
        {
            CurrentPlayer currentPlayer = Service.Get <CurrentPlayer>();
            int           num           = ContractUtils.CalculateDroidsInUse();

            if (num >= currentPlayer.CurrentDroidsAmount)
            {
                Contract contract = ContractUtils.FindBuildingToFinish();
                if (contract != null)
                {
                    int crystalCostToFinishContract = ContractUtils.GetCrystalCostToFinishContract(contract);
                    if (GameUtils.SpendCrystals(crystalCostToFinishContract))
                    {
                        NodeList <BuildingNode> nodeList = Service.Get <EntityController>().GetNodeList <BuildingNode>();
                        for (BuildingNode buildingNode = nodeList.Head; buildingNode != null; buildingNode = buildingNode.Next)
                        {
                            if (buildingNode.BuildingComp.BuildingTO.Key == contract.ContractTO.BuildingKey)
                            {
                                Service.Get <EventManager>().SendEvent(EventId.InitiatedBuyout, null);
                                Service.Get <ISupportController>().BuyOutCurrentBuildingContract(buildingNode.Entity, true);
                                return(true);
                            }
                        }
                    }
                }
            }
            return(false);
        }
        private void RecalculateXP()
        {
            GamePlayer worldOwner                  = GameUtils.GetWorldOwner();
            Inventory  inventory                   = worldOwner.Inventory;
            int        num                         = -worldOwner.CurrentXPAmount;
            NodeList <BuildingNode> nodeList       = Service.Get <EntityController>().GetNodeList <BuildingNode>();
            IDataController         dataController = Service.Get <IDataController>();

            for (BuildingNode buildingNode = nodeList.Head; buildingNode != null; buildingNode = buildingNode.Next)
            {
                BuildingTypeVO buildingType = buildingNode.BuildingComp.BuildingType;
                if (!ContractUtils.IsBuildingConstructing(buildingNode.Entity))
                {
                    num += buildingType.Xp;
                }
            }
            foreach (TroopTypeVO current in dataController.GetAll <TroopTypeVO>())
            {
                if (current.PlayerFacing && worldOwner.UnlockedLevels.Troops.GetLevel(current.UpgradeGroup) == current.Lvl && worldOwner.Faction == current.Faction && this.unlockController.IsTroopUnlocked(worldOwner, current))
                {
                    num += current.Xp;
                }
            }
            foreach (SpecialAttackTypeVO current2 in dataController.GetAll <SpecialAttackTypeVO>())
            {
                if (current2.PlayerFacing && worldOwner.UnlockedLevels.Starships.GetLevel(current2.UpgradeGroup) == current2.Lvl && worldOwner.Faction == current2.Faction && this.unlockController.IsSpecialAttackUnlocked(worldOwner, current2))
                {
                    num += current2.Xp;
                }
            }
            inventory.ModifyXP(num);
        }
Exemplo n.º 5
0
    public void SetData(Building building, Vector3 startPos, Transform viewport)
    {
        Vector3    endPos   = viewport.position - Vector3.ProjectOnPlane((viewport.position - startPos).normalized, Vector3.up) * 2f;
        Quaternion startRot = Quaternion.LookRotation((endPos - startPos).normalized, Vector3.up);
        Quaternion endRot   = Quaternion.LookRotation(Vector3.ProjectOnPlane(viewport.forward, Vector3.up), Vector3.up);

        transform.position   = startPos;
        transform.localScale = Vector3.zero;

        GetComponent <AnimateThis>().Transformate()
        .FromPosition(startPos)
        .ToPosition(endPos)
        .FromRotation(startRot)
        .ToRotation(endRot)
        .Duration(1).Start();

        BuildingNode node = building.node;

        Dictionary <string, string> attributes = node.allAttributes;
        List <string> keys = new List <string>();

        keys.AddRange(attributes.Keys);
        keys.Sort();
        string list = "";

        foreach (string key in keys)
        {
            list += key + ": " + attributes[key] + "\n";
        }

        transform.FindChild("PackageLabel").GetComponent <TextMesh>().text = node.pathName;
        transform.FindChild("NameLabel").GetComponent <TextMesh>().text    = node.name;
        transform.FindChild("MetricsLabel").GetComponent <TextMesh>().text = list;
    }
Exemplo n.º 6
0
        public DestroyBuildingUidCondition(ConditionVO vo, IConditionParent parent) : base(vo, parent)
        {
            this.buildingMatchUid = this.prepareArgs[1].ToLower();
            this.any = (this.buildingMatchUid == "any");
            this.buildingsDestroyed = 0;
            this.buildingsToDestroy = 0;
            string text = this.prepareArgs[0];

            if (text.Contains("%"))
            {
                this.byPercent = true;
                text           = text.Substring(0, text.Length - 1);
                int percent = Convert.ToInt32(text);
                if (this.any && this.byPercent)
                {
                    this.buildingsToDestroy = percent;
                    return;
                }
                EntityController        entityController = Service.EntityController;
                NodeList <BuildingNode> nodeList         = entityController.GetNodeList <BuildingNode>();
                int num = 0;
                for (BuildingNode buildingNode = nodeList.Head; buildingNode != null; buildingNode = buildingNode.Next)
                {
                    if (this.IsBuildingValid(buildingNode.BuildingComp))
                    {
                        num++;
                    }
                }
                this.buildingsToDestroy = IntMath.GetPercent(percent, num);
            }
            else
            {
                this.buildingsToDestroy = Convert.ToInt32(text);
            }
        }
        public DestroyBuildingTypeCondition(ConditionVO vo, IConditionParent parent) : base(vo, parent)
        {
            this.buildingMatchType = StringUtils.ParseEnum <BuildingType>(this.prepareArgs[1]);
            this.any = (this.buildingMatchType == BuildingType.Any);
            this.buildingsDestroyed = 0;
            this.buildingsToDestroy = 0;
            if (!this.prepareArgs[0].Contains("%"))
            {
                this.buildingsToDestroy = Convert.ToInt32(this.prepareArgs[0], CultureInfo.InvariantCulture);
                return;
            }
            this.byPercent = true;
            string text = this.prepareArgs[0];

            text = text.Substring(0, text.get_Length() - 1);
            int percent = Convert.ToInt32(text, CultureInfo.InvariantCulture);

            if (this.any && this.byPercent)
            {
                this.buildingsToDestroy = percent;
                return;
            }
            EntityController        entityController = Service.Get <EntityController>();
            NodeList <BuildingNode> nodeList         = entityController.GetNodeList <BuildingNode>();
            int num = 0;

            for (BuildingNode buildingNode = nodeList.Head; buildingNode != null; buildingNode = buildingNode.Next)
            {
                if (this.IsBuildingValid(buildingNode.BuildingComp))
                {
                    num++;
                }
            }
            this.buildingsToDestroy = IntMath.GetPercent(percent, num);
        }
Exemplo n.º 8
0
 internal BuildingEdge(BuildingNode a, BuildingNode b)
 {
     Nodes = new BuildingNode[] { a, b };
     foreach (BuildingNode n in Nodes)
     {
         n.cc.outgoingEdges++;
     }
 }
Exemplo n.º 9
0
 /*
  *	Edge connection will be set by connecting nodes
  *	They will call this method to set the connection in both ways
  */
 void SetEdgeConnection(BuildingNode connectingNode)
 {
     if (edgeNode) {
         nodeConnections.Add(connectingNode);
     } else {
         print("should not be getting called, is not edge node");
     }
 }
Exemplo n.º 10
0
 public static void GrantInstantBuildingUpgrade(RewardVO reward, CurrentPlayer cp)
 {
     for (int i = 0; i < reward.BuildingInstantUpgrades.Length; i++)
     {
         string[] array = reward.BuildingInstantUpgrades[i].Split(new char[]
         {
             ':'
         });
         int            num            = Convert.ToInt32(array[1], CultureInfo.InvariantCulture);
         string         text           = array[0];
         BuildingTypeVO buildingTypeVO = Service.Get <IDataController>().Get <BuildingTypeVO>(text);
         if (buildingTypeVO == null)
         {
             Service.Get <StaRTSLogger>().WarnFormat("buildingUiD {0} does not exist", new object[]
             {
                 text
             });
         }
         else
         {
             BuildingUpgradeCatalog  buildingUpgradeCatalog = Service.Get <BuildingUpgradeCatalog>();
             ISupportController      supportController      = Service.Get <ISupportController>();
             NodeList <BuildingNode> nodeList = Service.Get <EntityController>().GetNodeList <BuildingNode>();
             for (BuildingNode buildingNode = nodeList.Head; buildingNode != null; buildingNode = buildingNode.Next)
             {
                 BuildingTypeVO buildingType = buildingNode.BuildingComp.BuildingType;
                 if (buildingType.Lvl < num && buildingType.Type == buildingTypeVO.Type && buildingType.Type != BuildingType.Clearable)
                 {
                     BuildingTypeVO byLevel = buildingUpgradeCatalog.GetByLevel(buildingType.UpgradeGroup, num);
                     if (byLevel != null && byLevel.PlayerFacing)
                     {
                         if (!string.IsNullOrEmpty(buildingTypeVO.LinkedUnit))
                         {
                             if (ContractUtils.IsChampionRepairing(buildingNode.Entity))
                             {
                                 supportController.FinishCurrentContract(buildingNode.Entity, true);
                             }
                             if (cp.Inventory.Champion.GetItemAmount(buildingTypeVO.LinkedUnit) == 0)
                             {
                                 cp.OnChampionRepaired(buildingTypeVO.LinkedUnit);
                             }
                         }
                         supportController.StartBuildingUpgrade(byLevel, buildingNode.Entity, true);
                         int   boardX = buildingNode.Entity.Get <BoardItemComponent>().BoardItem.BoardX;
                         int   boardZ = buildingNode.Entity.Get <BoardItemComponent>().BoardItem.BoardZ;
                         float x;
                         float z;
                         EditBaseController.BuildingBoardToWorld(buildingNode.Entity, boardX, boardZ, out x, out z);
                         Vector3 worldLocation = new Vector3(x, 0f, z);
                         worldLocation.x = Units.BoardToWorldX(boardX);
                         worldLocation.z = Units.BoardToWorldX(boardZ);
                         Service.Get <WorldInitializer>().View.PanToLocation(worldLocation);
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 11
0
        public void ForceRepairOnAllBuildings(float healthPercentage)
        {
            NodeList <BuildingNode> nodeList = Service.Get <EntityController>().GetNodeList <BuildingNode>();

            for (BuildingNode buildingNode = nodeList.Head; buildingNode != null; buildingNode = buildingNode.Next)
            {
                this.ForceRepairOnBuilding(buildingNode.Entity, healthPercentage);
            }
        }
Exemplo n.º 12
0
 /*
  *	Edge connection will be set by connecting nodes
  *	They will call this method to set the connection in both ways
  */
 void SetEdgeConnection(BuildingNode connectingNode)
 {
     if (edgeNode)
     {
         nodeConnections.Add(connectingNode);
     }
     else
     {
         print("should not be getting called, is not edge node");
     }
 }
    private Block CreateBuildingBlock(BuildingNode building)
    {
        Block result = new Block();

        result.gameObject = (GameObject)GameObject.Instantiate(buildingPrefab, Vector3.zero, Quaternion.identity);
        result.gameObject.transform.localScale = new Vector3(building.groundSize, building.height, building.groundSize);
        result.gameObject.transform.Find("Building Object").GetComponent <Renderer> ().material.SetColor("_Color", new Color(building.color.x, building.color.y, building.color.z));
        result.width  = building.groundSize * 1.2f;
        result.length = result.width;
        result.gameObject.GetComponentInChildren <Building>().node = building;
        return(result);
    }
Exemplo n.º 14
0
        public void RegisterChampionPlatforms(CurrentBattle currentBattle)
        {
            SmartEntity             smartEntity = null;
            TroopTypeVO             troopTypeVO = null;
            bool                    flag        = false;
            NodeList <BuildingNode> nodeList    = Service.EntityController.GetNodeList <BuildingNode>();

            for (BuildingNode buildingNode = nodeList.Head; buildingNode != null; buildingNode = buildingNode.Next)
            {
                flag        = false;
                smartEntity = (SmartEntity)buildingNode.Entity;
                troopTypeVO = this.FindChampionTypeIfPlatform(smartEntity.BuildingComp.BuildingType);
                if (buildingNode.BuildingComp.BuildingType.Type == BuildingType.ChampionPlatform)
                {
                    if (currentBattle.Type == BattleType.PveAttack || currentBattle.Type == BattleType.ClientBattle || currentBattle.Type == BattleType.PveBuffBase || currentBattle.Type == BattleType.PvpAttackSquadWar)
                    {
                        if (troopTypeVO != null && smartEntity != null)
                        {
                            this.AddDefensiveChampionToPlatfrom(smartEntity, troopTypeVO);
                        }
                    }
                    else if (troopTypeVO != null && currentBattle.DisabledBuildings != null && !currentBattle.DisabledBuildings.Contains(buildingNode.BuildingComp.BuildingTO.Key))
                    {
                        if (currentBattle.IsPvP())
                        {
                            if (currentBattle.DefenderChampionsAvailable != null)
                            {
                                foreach (KeyValuePair <string, int> current in currentBattle.DefenderChampionsAvailable)
                                {
                                    if (current.Key == troopTypeVO.Uid && current.Value > 0)
                                    {
                                        flag = true;
                                    }
                                }
                            }
                        }
                        else if (currentBattle.Type == BattleType.PveDefend && !ContractUtils.IsBuildingUpgrading(smartEntity) && !ContractUtils.IsChampionRepairing(smartEntity))
                        {
                            Inventory inventory = Service.CurrentPlayer.Inventory;
                            bool      flag2     = inventory.Champion.HasItem(troopTypeVO.Uid) && inventory.Champion.GetItemAmount(troopTypeVO.Uid) > 0;
                            if (flag2)
                            {
                                flag = true;
                            }
                        }
                        if (flag)
                        {
                            this.AddDefensiveChampionToPlatfrom(smartEntity, troopTypeVO);
                        }
                    }
                }
            }
        }
Exemplo n.º 15
0
    void OnState()
    {
        if (state == UIState.CREATE)
        {
            int             buildingWidth   = 5;
            int             buildingHeight  = 5;
            Vector2Int      mouseCoord      = World.nodeCoordFromWorldPos((Vector2)Camera.main.ScreenToWorldPoint(Input.mousePosition) - new Vector2((buildingWidth - 1) / 2f * 1.044f, 0));
            PlaceableReturn placeableReturn = Placeable(mouseCoord.x, mouseCoord.y, buildingWidth, buildingHeight);

            RemoveMarkers();

            if (Input.GetMouseButtonDown(0) && placeableReturn.placeable)
            {
                Building            building = new Building(Tower);
                List <BuildingNode> newNodes = new List <BuildingNode>();
                foreach (PlanetNode n in placeableReturn.placeableNodes)
                {
                    BuildingNode newNode = new BuildingNode(n.Q, n.R, n.worldPos, building);
                    newNodes.Add(newNode);
                    World.nodes[new Vector2Int(n.Q, n.R)] = newNode;
                    World.planetNodes.TryRemove(new Vector2Int(n.Q, n.R), out _);
                }
                building.buildingNodes = newNodes;

                HashSet <PlanetNode> workerNodes = new HashSet <PlanetNode>();
                foreach (PlanetNode n in placeableReturn.placeableNodes)
                {
                    foreach (PlanetNode neighbour in n.getNeighbours())
                    {
                        if (!workerNodes.Contains(neighbour))
                        {
                            workerNodes.Add(neighbour);
                        }
                    }
                }
                building.workerNodes = workerNodes;

                InstantiateJob j = new InstantiateJob(building);
                JobManager.instance.QueueJob(j);

                _workerNodes = workerNodes;

                ExitState(UIState.CREATE);
                state = UIState.IDLE;
                EnterState(state);
            }
            else
            {
                SetMarkers(placeableReturn);
            }
        }
    }
Exemplo n.º 16
0
        private void RefreshTerrainBlendingNewMap()
        {
            EntityController        entityController = Service.Get <EntityController>();
            NodeList <BuildingNode> nodeList         = entityController.GetNodeList <BuildingNode>();

            for (BuildingNode buildingNode = nodeList.Head; buildingNode != null; buildingNode = buildingNode.Next)
            {
                if (buildingNode.BuildingComp.BuildingType.Type != BuildingType.Clearable && buildingNode.BuildingComp.BuildingType.Type != BuildingType.Trap)
                {
                    this.PaintTerrainPlacedArea(buildingNode.Entity);
                }
            }
        }
Exemplo n.º 17
0
        private void ApplyEquipmentBuffsToExistingBuildings()
        {
            if (this.defenderEquipmentBuffs.Count == 0)
            {
                return;
            }
            NodeList <BuildingNode> nodeList = Service.EntityController.GetNodeList <BuildingNode>();

            for (BuildingNode buildingNode = nodeList.Head; buildingNode != null; buildingNode = buildingNode.Next)
            {
                this.ApplyBuildingEquipmentBuffs((SmartEntity)buildingNode.Entity);
            }
            Service.EventManager.SendEvent(EventId.ShaderResetOnEntity, null);
        }
Exemplo n.º 18
0
        public RetainBuildingCondition(ConditionVO vo, IConditionParent parent, ConditionMatchType matchType) : base(vo, parent)
        {
            this.matchType  = matchType;
            this.buildingId = this.prepareArgs[1];
            this.any        = (this.buildingId == "any");
            if (matchType == ConditionMatchType.Uid)
            {
                this.level = Service.StaticDataController.Get <BuildingTypeVO>(this.buildingId).Lvl;
            }
            else if (!this.any && this.prepareArgs.Length > 2)
            {
                this.level = Convert.ToInt32(this.prepareArgs[2]);
            }
            else
            {
                this.level = 0;
            }
            this.buildingsDestroyed = 0;
            this.buildingsToDestroy = 0;
            EntityController        entityController = Service.EntityController;
            NodeList <BuildingNode> nodeList         = entityController.GetNodeList <BuildingNode>();
            BuildingNode            buildingNode     = nodeList.Head;
            int num = 0;

            while (buildingNode != null)
            {
                if (this.IsBuildingValid(buildingNode.BuildingComp))
                {
                    num++;
                }
                buildingNode = buildingNode.Next;
            }
            if (this.prepareArgs[0].Contains("%"))
            {
                this.byPercent = true;
                string text = this.prepareArgs[0];
                text = text.Substring(0, text.Length - 1);
                int percent = 100 - Convert.ToInt32(text);
                if (this.any && this.byPercent)
                {
                    this.buildingsToDestroy = percent;
                    return;
                }
                this.buildingsToDestroy = IntMath.GetPercent(percent, num);
            }
            else
            {
                this.buildingsToDestroy = num - Convert.ToInt32(this.prepareArgs[0]);
            }
        }
    public override bool build()
    {
        /*TODO
         * scan the area around the node for other buildings,
         * and weight the random number based on their type.
         * The more buildings of one type around a new node,
         * the more likely it is to instantiate as that type
         */
        if (concreteImplementation == null)
        {
            System.Random rnd = new System.Random();
            SortedDictionary <BuildingClass, float> building_weights = buildingWeights();

            BuildingClass most_frequent    = BuildingClass.Residential;
            float         weighting_factor = 0.0f;
            float         temp_output      = 0.0f;
            foreach (BuildingClass b in building_weights.Keys)
            {
                building_weights.TryGetValue(b, out temp_output);
                if (temp_output > weighting_factor)
                {
                    weighting_factor = temp_output;
                    most_frequent    = b;
                }
            }

            switch ((rnd.NextDouble() <= weighting_factor ? (int)most_frequent : rnd.Next(buildingClasses.Length)))
            {
            case (int)BuildingClass.Residential:
                concreteImplementation = new ResidentialBuildingNode(this.GetComponent <Transform>().position);
                break;

            case (int)BuildingClass.Commercial:
                concreteImplementation = new CommercialBuildingNode(this.GetComponent <Transform>().position);
                break;

            default:
                print("No corosponding building type");
                return(false);
            }

            this.setConstructed(true);
            this.GetComponent <BoxCollider>().enabled = false;
            concreteImplementation.build();
            concreteImplementation.setConstructed(true);
        }
        return(true);
    }
Exemplo n.º 20
0
        protected override List <SmartEntity> GetBuildingEntityListByType(BuildingType buildingType)
        {
            EntityController        entityController = Service.EntityController;
            List <SmartEntity>      list             = new List <SmartEntity>();
            NodeList <BuildingNode> nodeList         = entityController.GetNodeList <BuildingNode>();

            for (BuildingNode buildingNode = nodeList.Head; buildingNode != null; buildingNode = buildingNode.Next)
            {
                BuildingType type = buildingNode.BuildingComp.BuildingType.Type;
                if (buildingType == type)
                {
                    list.Add((SmartEntity)buildingNode.Entity);
                }
            }
            return(list);
        }
Exemplo n.º 21
0
    public void BuildBuildingOn(BuildingNode node)
    {
        if (PlayerStats.Money < buildingToBuild.cost)
        {
            Debug.Log("Not enough money to build that");
            return;
        }

        PlayerStats.Money -= buildingToBuild.cost;

        GameObject building = (GameObject)Instantiate(buildingToBuild.prefab, node.GetBuildPosition(), Quaternion.identity);

        node.building = building;

        Debug.Log("Building Built! Money Remaining: " + PlayerStats.Money);
    }
Exemplo n.º 22
0
    public bool available = true;     // can a passenger visit this node?

    public InternalBuildingNode(BuildingNode externalNode, Vector3 building_position,
                                Vector3 nodePosition, GameObject _door, string _name)
    {
        edgeNode       = externalNode.edgeNode;
        connectingNode = externalNode.connectingNode;
        entrance       = externalNode.entrance;
        //employee = externalNode.employee;

        category = externalNode.category;
        number   = externalNode.number;

        buildingPosition = building_position;
        position3        = nodePosition;

        door = _door;
        name = _name;
    }
    public InternalBuildingNode(BuildingNode externalNode, Vector3 building_position, 
								Vector3 nodePosition, GameObject _door, string _name)
    {
        edgeNode = externalNode.edgeNode;
        connectingNode = externalNode.connectingNode;
        entrance = externalNode.entrance;
        //employee = externalNode.employee;

        category = externalNode.category;
        number = externalNode.number;

        buildingPosition = building_position;
        position3 = nodePosition;

        door = _door;
        name = _name;
    }
Exemplo n.º 24
0
        public override void Execute()
        {
            base.Execute();
            NodeList <BuildingNode> nodeList = Service.Get <EntityController>().GetNodeList <BuildingNode>();

            for (BuildingNode buildingNode = nodeList.Head; buildingNode != null; buildingNode = buildingNode.Next)
            {
                if (buildingNode.BuildingComp.BuildingType.BuildingID.Equals(this.prepareArgs[0], 5))
                {
                    Entity entity = buildingNode.Entity;
                    Service.Get <BuildingController>().ClearBuildingHighlight(entity);
                    Service.Get <UXController>().MiscElementsManager.HideHighlight();
                    break;
                }
            }
            this.parent.ChildComplete(this);
        }
Exemplo n.º 25
0
        private void SetBuildingsToAttack(int x, int z, SpatialIndex spatialIndex)
        {
            Board <Entity>          board    = Service.Get <BoardController>().Board;
            BoardCell <Entity>      cellAt   = board.GetCellAt(x, z, true);
            NodeList <BuildingNode> nodeList = Service.Get <EntityController>().GetNodeList <BuildingNode>();

            spatialIndex.AlreadyScannedBuildingsToAttack = true;
            for (BuildingNode buildingNode = nodeList.Head; buildingNode != null; buildingNode = buildingNode.Next)
            {
                SmartEntity smartEntity = (SmartEntity)buildingNode.Entity;
                if (smartEntity.DamageableComp != null && this.IsAliveHealthNode(smartEntity))
                {
                    int squaredDistance = this.CalcSquredDistanceFromTransformToCell(smartEntity.TransformComp, cellAt);
                    int nearness        = this.CalcNearness(squaredDistance);
                    spatialIndex.AddBuildingsToAttack(smartEntity, nearness);
                }
            }
        }
Exemplo n.º 26
0
        internal static Graph BuildGrid(int x, int y, float xStep, float yStep, float xRandRange, float yRandRange)
        {
            List <BuildingNode> nodes = new List <BuildingNode>();
            List <BuildingEdge> edges = new List <BuildingEdge>();
            float yPos = 0;

            BuildingNode[,] grid = new BuildingNode[x, y];
            for (int j = 0; j < y; j++)
            {
                float xPos = (j % 2 == 0)? 0 : yStep / 2; // stagger the rows
                for (int i = 0; i < x; i++)
                {
                    //walk
                    xPos += xStep + 2 * xRandRange * ((float)Rand.NextDouble()) - xRandRange;
                    yPos += 2 * yRandRange * ((float)Rand.NextDouble()) - yRandRange;
                    //init the node
                    BuildingNode node = new BuildingNode {
                        cc = new BuildingCC(), xPos = xPos, yPos = yPos, prio = nodes.Count, AdjacentNodes = new List <BuildingNode>()
                    };
                    //store it
                    nodes.Add(node);
                    grid[i, j] = node;
                    //build edges
                    if (i > 0)
                    {
                        edges.Add(new BuildingEdge(node, grid[i - 1, j]));
                    }
                    if (j > 0)
                    {
                        edges.Add(new BuildingEdge(node, grid[i, j - 1]));
                    }
                    if (j > 0 && i > 0)
                    {
                        edges.Add(new BuildingEdge(node, grid[i - 1, j - 1]));
                    }
                }
                yPos += yStep;
            }
            return(new Graph {
                Nodes = nodes, Edges = edges
            });
        }
Exemplo n.º 27
0
        protected override void Update(uint dt)
        {
            this.HandleDeferredUserInuput();
            this.battleController.UpdateBattleTime(dt);
            if (this.audioResetDeltaAccumulator >= this.audioResetDeltaMax)
            {
                this.audioManager.ResetBattleAudioFlags();
                this.audioResetDeltaAccumulator = 0u;
            }
            else
            {
                this.audioResetDeltaAccumulator += dt;
            }
            int num = 0;

            for (BuildingNode buildingNode = this.buildingNodeList.Head; buildingNode != null; buildingNode = buildingNode.Next)
            {
                num += this.battleController.GetHealth(buildingNode.BuildingComp.BuildingType.Type, buildingNode.HealthComp);
            }
            bool flag = true;

            for (TroopNode troopNode = this.troopNodeList.Head; troopNode != null; troopNode = troopNode.Next)
            {
                if (troopNode.TeamComp.TeamType == TeamType.Attacker && !troopNode.HealthComp.IsDead() && !troopNode.TroopComp.TroopType.IsHealer)
                {
                    flag = false;
                    break;
                }
            }
            if (flag && this.specialAttackController.HasUnexpendedSpecialAttacks())
            {
                flag = false;
            }
            this.battleController.UpdateCurrentHealth(num);
            if (flag)
            {
                this.battleController.OnAllTroopsDead();
            }
            TeamType type = (!this.battleController.GetCurrentBattle().IsRaidDefense()) ? TeamType.Attacker : TeamType.Defender;

            this.squadTroopAttackController.UpdateSquadTroopSpawnQueue(type);
        }
Exemplo n.º 28
0
        public override void GetProgress(out int current, out int total)
        {
            current = 0;
            total   = this.threshold;
            EntityController        entityController = Service.Get <EntityController>();
            IDataController         dataController   = Service.Get <IDataController>();
            NodeList <BuildingNode> nodeList         = entityController.GetNodeList <BuildingNode>();

            for (BuildingNode buildingNode = nodeList.Head; buildingNode != null; buildingNode = buildingNode.Next)
            {
                if (!ContractUtils.IsBuildingConstructing(buildingNode.Entity))
                {
                    BuildingTypeVO vo = dataController.Get <BuildingTypeVO>(buildingNode.BuildingComp.BuildingTO.Uid);
                    if (this.IsBuildingValid(vo))
                    {
                        current++;
                    }
                }
            }
        }
Exemplo n.º 29
0
        private void RemoveBuffShaders(uint id, object cookie)
        {
            NodeList <BuildingNode> nodeList = Service.Get <EntityController>().GetNodeList <BuildingNode>();

            for (BuildingNode buildingNode = nodeList.Head; buildingNode != null; buildingNode = buildingNode.Next)
            {
                SmartEntity   smartEntity = (SmartEntity)buildingNode.Entity;
                BuffComponent buffComp    = smartEntity.BuffComp;
                if (buffComp != null && buffComp.Buffs.Count != 0)
                {
                    this.RestoreShadersAfterBuff(smartEntity);
                    if (this.shaderSwappedBuffs.ContainsKey(smartEntity))
                    {
                        this.shaderSwappedBuffs.Remove(smartEntity);
                    }
                }
            }
            this.oldMaterials.Clear();
            this.shaderSwappedMaterials.Clear();
            this.shaderSwappedBuffs.Clear();
        }
Exemplo n.º 30
0
        public bool FoundFirstEmptySpaceFor(BuildingTypeVO buildingData)
        {
            int num   = 42;
            int num2  = 42;
            int num3  = 0 - num / 2;
            int num4  = 0 - num2 / 2;
            int num5  = num / 2;
            int num6  = num2 / 2;
            int sizeX = buildingData.SizeX;
            int sizeY = buildingData.SizeY;

            for (int i = num4 / 2; i <= num6 / 2; i++)
            {
                for (int j = num3 / 2; j <= num5 / 2; j++)
                {
                    int num7 = j + sizeX;
                    int num8 = i + sizeY;
                    if (j >= num3 && i >= num4 && num7 - 1 <= num5 && num8 - 1 <= num6)
                    {
                        bool flag = false;
                        NodeList <BuildingNode> nodeList = Service.Get <EntityController>().GetNodeList <BuildingNode>();
                        for (BuildingNode buildingNode = nodeList.Head; buildingNode != null; buildingNode = buildingNode.Next)
                        {
                            if (this.isOverlapping(buildingNode.BuildingComp.BuildingTO, buildingData, j, i))
                            {
                                flag = true;
                                break;
                            }
                        }
                        if (!flag)
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Exemplo n.º 31
0
        private Dictionary <BuildingType, HashSet <Renderer> > GetAllRenderersToCombine()
        {
            EntityController entityController = Service.Get <EntityController>();
            Dictionary <BuildingType, HashSet <Renderer> > dictionary = new Dictionary <BuildingType, HashSet <Renderer> >();
            NodeList <BuildingNode> nodeList = entityController.GetNodeList <BuildingNode>();

            for (BuildingNode buildingNode = nodeList.Head; buildingNode != null; buildingNode = buildingNode.Next)
            {
                BuildingType type        = buildingNode.BuildingComp.BuildingType.Type;
                SmartEntity  smartEntity = (SmartEntity)buildingNode.Entity;
                if (this.IsBuildingTypeEligible(type) && this.IsEntityEligibleForEligibleBuildingType(smartEntity))
                {
                    HashSet <Renderer> hashSet;
                    if (!dictionary.TryGetValue(type, out hashSet))
                    {
                        hashSet          = new HashSet <Renderer>();
                        dictionary[type] = hashSet;
                    }
                    this.AddRenderersFromEntity(hashSet, smartEntity);
                }
            }
            return(dictionary);
        }
Exemplo n.º 32
0
    public Node CreateNodeModel(string pathSeparator, string path, JSONObject folderOrFile, Dictionary <BuildingProperty, MetricMapping> mappings)
    {
        if (folderOrFile.GetField("type").str.Equals("Folder"))
        {
            List <Node> list = new List <Node> ();
            foreach (JSONObject child in folderOrFile.GetField("children").list)
            {
                list.Add(CreateNodeModel(pathSeparator, path + ((path.Length != 0) ? pathSeparator : "") + folderOrFile.GetField("name").str, child, mappings));
            }
            return(new StreetNode(list.ToArray()));
        }
        else if (folderOrFile.GetField("type").str.Equals("File"))
        {
            JSONObject   attribs  = folderOrFile.GetField("attributes");
            BuildingNode building = new BuildingNode();
            building.pathName = path;
            building.name     = folderOrFile.GetField("name").str;
            building.heightMappedAttribute = mappings[BuildingProperty.Height].metricName;
            building.groundMappedAttribute = mappings[BuildingProperty.Width].metricName;
            building.colorMappedAttribute  = mappings[BuildingProperty.Red].metricName;

            building.height     = mappings [BuildingProperty.Height].Apply(attribs);
            building.groundSize = mappings [BuildingProperty.Width].Apply(attribs);

            building.color = new Vector3(
                mappings[BuildingProperty.Red].Apply(attribs), mappings[BuildingProperty.Green].Apply(attribs), mappings[BuildingProperty.Blue].Apply(attribs)
                );

            foreach (KeyValuePair <string, string> attrib in attribs.ToDictionary())
            {
                building.allAttributes[attrib.Key] = attrib.Value;
            }

            return(building);
        }
        return(null);
    }