Ejemplo n.º 1
0
        public static Pilot CreateRandom(Teams.Team inTeam, int inLevel = 1)
        {
            if (inTeam == null)
            {
                return(null);
            }

            GameObject GO_Pilot = new GameObject();
            Pilot      OutPilot = GO_Pilot.AddComponent <Pilot>();

            OutPilot.Level  = inLevel;
            OutPilot.Gender = GameLoop.MAIN.RandomHelper.Primary.Next(100) <= 60 ? PilotGender.Male : PilotGender.Female;

            if (OutPilot.Gender == PilotGender.Male)
            {
                OutPilot._Name_First = PilotNames.Random_First_Male();
            }
            else
            {
                OutPilot._Name_First = PilotNames.Random_First_Female();
            }

            OutPilot._Name_Last = PilotNames.Random_Last();

            GO_Pilot.name             = OutPilot.Name_Full;
            GO_Pilot.transform.parent = inTeam.gameObject.transform;

            return(OutPilot);
        }
Ejemplo n.º 2
0
        public static Pilot CreateFromSerialized(Teams.Team inTeam, _Pilot_Serialized inSerialized)
        {
            if (inTeam == null)
            {
                return(null);
            }

            GameObject GO_Pilot = new GameObject();
            Pilot      OutPilot = GO_Pilot.AddComponent <Pilot>();


            if (inSerialized.Level <= 0)
            {
                inSerialized.Level = 1;
            }

            OutPilot.Level = inSerialized.Level;

            if (inSerialized.Level_XPThisLevel < 0)
            {
                inSerialized.Level_XPThisLevel = 0;
            }

            OutPilot.Level_XPThisLevel = inSerialized.Level_XPThisLevel;

            if (Enum.IsDefined(typeof(PilotGender), inSerialized.Gender))
            {
                OutPilot.Gender = (PilotGender)inSerialized.Gender;
            }
            else
            {
                OutPilot.Gender = PilotGender.Unknown;
            }


            if (string.IsNullOrWhiteSpace(inSerialized.Name_First))
            {
                if (OutPilot.Gender == PilotGender.Male)
                {
                    OutPilot._Name_First = PilotNames.Random_First_Male();
                }
                else if (OutPilot.Gender == PilotGender.Female)
                {
                    OutPilot._Name_First = PilotNames.Random_First_Female();
                }
                else
                {
                    OutPilot._Name_First = PilotNames.Random_First_Male();
                }
            }
            else
            {
                OutPilot._Name_First = inSerialized.Name_First;
            }


            if (string.IsNullOrWhiteSpace(inSerialized.Name_Last))
            {
                OutPilot._Name_Last = PilotNames.Random_Last();
            }
            else
            {
                OutPilot._Name_Last = inSerialized.Name_Last;
            }


            if (!string.IsNullOrWhiteSpace(inSerialized.CallSign))
            {
                OutPilot._Callsign = inSerialized.CallSign;
            }

            //ToDo ShipIDPreferences:
            //string.Join(",", )
            //"".Split(",")

            GO_Pilot.name             = OutPilot.Name_Full;
            GO_Pilot.transform.parent = inTeam.gameObject.transform;

            return(OutPilot);
        }