Example #1
0
 public static Materials.Asset BuildingToMaterial(Factions.Faction faction)
 {
     if (faction == Factions.Faction.Player)
     {
         return(Materials.Asset.Building_Player);
     }
     else if (faction == Factions.Faction.Enemy_1)
     {
         return(Materials.Asset.Building_Enemy_1);
     }
     else if (faction == Factions.Faction.Enemy_2)
     {
         return(Materials.Asset.Building_Enemy_2);
     }
     else if (faction == Factions.Faction.Enemy_3)
     {
         return(Materials.Asset.Building_Enemy_3);
     }
     else if (faction == Factions.Faction.Enemy_4)
     {
         return(Materials.Asset.Building_Enemy_4);
     }
     else if (faction == Factions.Faction.Police)
     {
         return(Materials.Asset.Building_Police);
     }
     else if (faction == Factions.Faction.Neutral)
     {
         return(Materials.Asset.Building_Neutral);
     }
     else
     {
         return(0);
     }
 }
Example #2
0
        public FactionOverlay(Jeu _jeu, suiteTraitement suite)
            : base(_jeu, Overlay.Position.CENTRE, 400, 680 + 80, 0, 0, "Seigneurs de Guerre - Choisissez les factions")
        {
            _modalOverlay = ModalOverlay.FACTIONS;

            // Bouton Démarrer
            Bouton demarrer = new Bouton(_jeu, _xoverlay + 16, _yoverlay + _height - 48, "Démarrer", null, _jeu.isoFont);

            demarrer.click = delegate(Controle clicked, int x, int y, bool leftClick, bool rightClick, bool released) {
                if (released)
                {
                    _jeu.popOverlay();
                    // Suite du traitement - début du jeu
                    suite();
                }
            };
            _controles.Add(demarrer);

            // Boutons des factions, 2 colonnes
            Bouton[] factions = new Bouton[_jeu.factions.nbFactions];
            int      xbouton  = _xoverlay + 16;
            int      ybouton  = _yoverlay + 48;

            for (int i = 1; i <= factions.Length; i++)
            {
                Factions.Faction f   = _jeu.factions.getFaction(i);
                string           nom = ("           " + f.nom + "                           ").Substring(0, 32);
                factions[i - 1]          = new Bouton(_jeu, xbouton, ybouton, nom, f.humanPlayer ? _jeu.texHumain : _jeu.texCPU, _jeu.isoFont);
                factions[i - 1].userData = i;
                factions[i - 1].click    = delegate(Controle clicked, int x, int y, bool leftClick, bool rightClick, bool released) {
                    if (released)
                    {
                        Factions.Faction fac = _jeu.factions.getFaction(clicked.userData);
                        fac.humanPlayer          ^= true;
                        ((Bouton)clicked).picture = fac.humanPlayer ? _jeu.texHumain : _jeu.texCPU;
                    }
                };
                _controles.Add(factions[i - 1]);
                ybouton += 80;
            }
        }
Example #3
0
        //==============================================================================
        //
        //                                    METHODS
        //
        //==============================================================================



        public virtual void DeSerialize(_ShipSerialized inRawShip)
        {
            #region FactionID

            if (string.IsNullOrWhiteSpace(inRawShip.FactionID))
            {
                Debug.LogWarning($"{this.GetType().Name} has no faction assigned, and cannot be created.");
                return;
            }
            else
            {
                if (!inRawShip.FactionID.StartsWith("faction."))
                {
                    inRawShip.FactionID = "faction." + inRawShip.FactionID;
                }

                if (GameLoop.MAIN.FactionManager.FactionIDExists(inRawShip.FactionID))
                {
                    this._Faction = GameLoop.MAIN.FactionManager.GetFactionFromID(inRawShip.FactionID);
                }
                else
                {
                    //ToDo: Assign to a neutral faction that any faction can use?
                    Debug.LogError($"{this.GetType().Name} has a non-existent faction assigned ({inRawShip.FactionID}) and cannot be created.");
                    return;
                }
            }

            #endregion


            #region Name

            if (!string.IsNullOrWhiteSpace(inRawShip.Name))
            {
                this._Name = inRawShip.Name;
            }
            else
            {
                Debug.LogWarning($"Creating a {this.GetType().Name} with no name defined.");
            }

            #endregion


            #region Ship ID - UI

            if (!string.IsNullOrWhiteSpace(inRawShip.ID))
            {
                this.IDType_UI = inRawShip.ID.ToLowerInvariant();

                if (!this.IDType_UI.StartsWith("ship."))
                {
                    this.IDType_UI = "ship." + this.IDType_UI;
                }

                if (_ShipRegistry.ShipIDs.ContainsKey(this.IDType_UI))
                {
                    Debug.LogError($"Could not Create a new {this.GetType().Name}!  Ship ID:'{this.IDType_UI}' is already registered in the system.");
                    return;
                }
            }
            else
            {
                if (!string.IsNullOrWhiteSpace(this.Name))
                {
                    string ShipID = Modding.ModParser.ConvertStringToID(this.Name.ToLowerInvariant());

                    if (!string.IsNullOrWhiteSpace(ShipID))
                    {
                        this.IDType_UI = $"ship.{this.GetType().Name.ToLowerInvariant()}.{ShipID}";
                    }
                }

                //ships.interceptor.37129317290317
                if (string.IsNullOrWhiteSpace(this.IDType_UI))
                {
                    this.IDType_UI = $"ship.{this.GetType().Name.ToLowerInvariant()}.{GameLoop.MAIN.RandomHelper.Primary.Next(int.MaxValue)}";
                }

                if (_ShipRegistry.ShipIDs.ContainsKey(this.IDType_UI))
                {
                    //Attempt generating another unique ID
                    this.IDType_UI = this.IDType_UI + GameLoop.MAIN.RandomHelper.Primary.Next(999999);

                    if (_ShipRegistry.ShipIDs.ContainsKey(this.IDType_UI))
                    {
                        Debug.LogError($"Could not Create a new {this.GetType().Name}!  Ship ID:'{this.IDType_UI}' is already registered in the system.");
                        return;
                    }
                }
            }

            #endregion


            #region Ship ID - Internal

            for (int i = 0; i < 5; i++)
            {
                this.IDType_Internal = GameLoop.MAIN.RandomHelper.Primary.Next(int.MaxValue);
                if (_ShipRegistry.ShipList.ContainsKey(this.IDType_Internal))
                {
                    if (i == 4)
                    {
                        Debug.LogError($"Could not Create a new {this.GetType().Name}!  Internal Ship ID:'{this.IDType_Internal}' is already registered in the system.");
                        return;
                    }
                }
                else
                {
                    break;
                }
            }

            #endregion


            #region Hull HP

            if (inRawShip.HP < 1)
            {
                Debug.LogWarning($"Problem parsing {this.GetType().Name}. Attempted to set the HP for ship to {inRawShip.HP}, defaulting to {DEFAULT_HP}");
                this._HullHP_Maximum = DEFAULT_HP;
            }
            else
            {
                this._HullHP_Maximum = inRawShip.HP;
            }

            #endregion



            _ShipRegistry.AddShipType(this.IDType_Internal, this.IDType_UI, this);
        }