Example #1
0
 void Start()
 {
     //if it's not a MP game:
     if (MultiplayerGame == false)
     {
         //Set the player's initial cam position (looking at the faction's capital building):
         CamMov.LookAt(Factions[PlayerFactionID].CapitalBuilding.transform.position);
         CamMov.SetMiniMapCursorPos(Factions[PlayerFactionID].CapitalBuilding.transform.position);
     }
 }
Example #2
0
        void Start()
        {
            /*because the building's main compoment is a network behaviour. The building centers, already present in the scene when it loads, will be disabled in an offline
             * game because their NetworkIdentity components can not connect to a server. Therefore, we need to enable under "Start ()".
             * */
            if (Factions.Count > 0)
            {
                for (int i = 0; i < Factions.Count; i++)
                {
                    if (Factions [i].CapitalBuilding != null)
                    {
                        Factions [i].CapitalBuilding.gameObject.SetActive(true);
                    }

                    int FactionTypeID = GetFactionTypeID(Factions[i].Code);      //Get the faction type ID depending on the code presented with this faction.

                    if (FactionTypeID >= 0)                                      //if this is a valid faction
                    {
                        Factions [i].TypeName = FactionDef [FactionTypeID].Name; //get its name
                    }

                    //Depending on the faction type, add extra units/buildings (if there's actually any) to be created for each faction:
                    if (MultiplayerGame == false || (MultiplayerGame == true && PlayerFactionID == i))
                    {
                        if (FactionTypeID >= 0)                           //if the code actually refers to a valid faction type

                        {
                            Factions [i].TypeID  = FactionTypeID;
                            Factions[i].TypeName = FactionDef [FactionTypeID].Name;
                            if (Factions [i].PlayerControl == true)                                                //if this faction is player controlled:
                            {
                                if (FactionDef [FactionTypeID].ExtraBuildings.Length > 0)                          //if the faction type has extra buildings:
                                {
                                    for (int j = 0; j < FactionDef [FactionTypeID].ExtraBuildings.Length; j++)     //go through them:
                                    {
                                        BuildingMgr.AllBuildings.Add(FactionDef[FactionTypeID].ExtraBuildings[j]); //add the extra buildings so that this faction can use them.
                                    }
                                }
                            }
                            else                                                                                                          //NPC players.
                            {
                                if (FactionDef [FactionTypeID].ExtraBuildings.Length > 0)                                                 //if the faction type has extra buildings:
                                {
                                    for (int j = 0; j < FactionDef [FactionTypeID].ExtraBuildings.Length; j++)                            //go through them:
                                    {
                                        Factions[i].FactionMgr.BuildingMgr.AllBuildings.Add(FactionDef[FactionTypeID].ExtraBuildings[j]); //add the extra buildings so that this faction can use them.
                                    }
                                }

                                //special buildings for NPC factions:
                                if (FactionDef [FactionTypeID].BuildingCenter != null)
                                {
                                    Factions [i].FactionMgr.BuildingMgr.BuildingCenter = FactionDef [FactionTypeID].BuildingCenter;
                                }
                                if (FactionDef [FactionTypeID].DropOffBuilding != null)
                                {
                                    Factions [i].FactionMgr.BuildingMgr.DropOffBuilding = FactionDef [FactionTypeID].DropOffBuilding;
                                }
                                if (FactionDef [FactionTypeID].PopulationBuilding != null)
                                {
                                    Factions [i].FactionMgr.BuildingMgr.PopulationBuilding = FactionDef [FactionTypeID].PopulationBuilding;
                                }
                            }
                        }
                    }
                }
            }


            //if it's not a MP game:
            if (MultiplayerGame == false)
            {
                //Set the player's initial cam position (looking at the faction's capital building):
                CamMov.LookAt(Factions [PlayerFactionID].CapitalBuilding.transform.position);
                CamMov.SetMiniMapCursorPos(Factions [PlayerFactionID].CapitalBuilding.transform.position);
            }
        }
Example #3
0
        void Start()
        {
            /*because the building's main compoment is a network behaviour. The building centers, already present in the scene when it loads, will be disabled in an offline
             * game because their NetworkIdentity components can not connect to a server. Therefore, we need to enable under "Start ()".
             * */
            if (Factions.Count > 0)
            {
                for (int i = 0; i < Factions.Count; i++)
                {
                    if (Factions[i].CapitalBuilding != null)
                    {
                        Factions[i].CapitalBuilding.gameObject.SetActive(true);
                    }

                    if (Factions[i].TypeInfo != null)
                    { //if this is a valid faction
                        //Depending on the faction type, add extra units/buildings (if there's actually any) to be created for each faction:
                        if (MultiplayerGame == false || (MultiplayerGame == true && PlayerFactionID == i))
                        {
                            if (Factions[i].PlayerControl == true)
                            {                                                                                     //if this faction is player controlled:
                                if (Factions[i].TypeInfo.ExtraBuildings.Count > 0)
                                {                                                                                 //if the faction type has extra buildings:
                                    for (int j = 0; j < Factions[i].TypeInfo.ExtraBuildings.Count; j++)
                                    {                                                                             //go through them:
                                        if (Factions[i].TypeInfo.ExtraBuildings[j] != null)                       //only if there's an assigned building.
                                        {
                                            BuildingMgr.AllBuildings.Add(Factions[i].TypeInfo.ExtraBuildings[j]); //add the extra buildings so that this faction can use them.
                                        }
                                    }
                                }
                            }
                            else
                            {                                                                                                      //NPC players.
                                if (Factions[i].TypeInfo.ExtraBuildings.Count > 0)
                                {                                                                                                  //if the faction type has extra buildings:
                                    Factions[i].FactionMgr.BuildingMgr.AllBuildings.AddRange(Factions[i].TypeInfo.ExtraBuildings); //add the extra buildings so that this faction can use them.
                                }

                                //special buildings for NPC factions:
                                if (Factions[i].TypeInfo.BuildingCenter != null)
                                {
                                    Factions[i].FactionMgr.BuildingMgr.BuildingCenter = Factions[i].TypeInfo.BuildingCenter;
                                }
                                if (Factions[i].TypeInfo.DropOffBuilding != null)
                                {
                                    Factions[i].FactionMgr.BuildingMgr.DropOffBuilding = Factions[i].TypeInfo.DropOffBuilding;
                                }
                                if (Factions[i].TypeInfo.PopulationBuilding != null)
                                {
                                    Factions[i].FactionMgr.BuildingMgr.PopulationBuilding = Factions[i].TypeInfo.PopulationBuilding;
                                }
                            }

                            Factions[i].FactionMgr.Limits.Clear();
                            //set the faction type limits in the faction manager:
                            foreach (FactionTypeInfo.FactionLimitsVars LimitElem in Factions[i].TypeInfo.Limits)
                            {
                                FactionTypeInfo.FactionLimitsVars CopyLimitElem = new FactionTypeInfo.FactionLimitsVars();
                                CopyLimitElem.Code          = LimitElem.Code;
                                CopyLimitElem.MaxAmount     = LimitElem.MaxAmount;
                                CopyLimitElem.CurrentAmount = 0;

                                Factions[i].FactionMgr.Limits.Add(CopyLimitElem);
                            }
                        }
                    }
                }
            }


            //if it's not a MP game:
            if (MultiplayerGame == false)
            {
                //Set the player's initial cam position (looking at the faction's capital building):
                CamMov.LookAt(Factions[PlayerFactionID].CapitalBuilding.transform.position);
                CamMov.SetMiniMapCursorPos(Factions[PlayerFactionID].CapitalBuilding.transform.position);
            }
        }