Exemplo n.º 1
0
 public SetupState(StateManager managerRef)
 {
     manager = managerRef;
     gData = GameObject.Find("GameManager").GetComponent<GalaxyData>();
     gameData = GameObject.Find("GameManager").GetComponent<GlobalGameData>();
     Debug.Log("In SetupState");
 }
Exemplo n.º 2
0
        public static void CreateNewStellarEvent(string civID, string locationName, string systemLocationID, string planetLocationID, eEventType eType, eEventLevel eLevel, eEventScope eScope, int Value1, string Label1)
        {
            GlobalGameData gDataRef = GameObject.Find("GameManager").GetComponent <GlobalGameData>();
            string         origDesc = DataManager.Descriptions[eType];
            string         newDesc  = origDesc;
            GameEvent      newEvent = new GameEvent();

            newEvent.Type             = eType;
            newEvent.Level            = eLevel;
            newEvent.Scope            = eScope;
            newEvent.CivID            = civID;
            newEvent.SystemLocationID = systemLocationID;
            newEvent.PlanetLocationID = planetLocationID;
            newEvent.EventIsNew       = true;
            newEvent.Date             = gDataRef.GameDate; // set the date

            newEvent.Description = DataManager.Descriptions[eType];
            if (origDesc.Contains("[VALUE]"))
            {
                string valueReplace;
                valueReplace         = origDesc.Replace("[VALUE]", Mathf.Abs(Value1).ToString("N0"));
                newDesc              = valueReplace;
                newEvent.Description = newDesc;
            }

            if (origDesc.Contains("[PLANET]"))
            {
                string planetReplace;
                planetReplace        = newDesc.Replace("[PLANET]", locationName);
                newDesc              = planetReplace;
                newEvent.Description = newDesc;
            }

            HelperFunctions.DataRetrivalFunctions.GetCivilization(civID).LastTurnEvents.Add(newEvent); // add the event to the correct civ list
        }
 void Awake()
 {
     gDataRef        = GameObject.Find("GameManager").GetComponent <GlobalGameData>();
     graphicsDataRef = GameObject.Find("GameManager").GetComponent <GraphicAssets>(); // get graphics
     characterWindow = GameObject.Find("Character Window Panel");
     blockingPanel   = GameObject.Find("Blocking Panel");
     age             = characterWindow.transform.Find("Age Value").GetComponent <Text>();
     health          = characterWindow.transform.Find("Health Value").GetComponent <Text>();
     wealth          = characterWindow.transform.Find("Wealth Value").GetComponent <Text>();
     intelligence    = characterWindow.transform.Find("Intelligence Value").GetComponent <Text>();
     influence       = characterWindow.transform.Find("Influence Value").GetComponent <Text>();
     honor           = characterWindow.transform.Find("Loyalty Value").GetComponent <Text>();
     intel           = characterWindow.transform.Find("Intel Value").GetComponent <Text>();
     charm           = characterWindow.transform.Find("Charisma Value").GetComponent <Text>();
     drive           = characterWindow.transform.Find("Drive Value").GetComponent <Text>();
     piety           = characterWindow.transform.Find("Piety Value").GetComponent <Text>();
     empathy         = characterWindow.transform.Find("Empathy Value").GetComponent <Text>();
     passion         = characterWindow.transform.Find("Will Value").GetComponent <Text>();
     history         = characterWindow.transform.Find("History Text").GetComponent <Text>();
     CommText        = characterWindow.transform.Find("Comm Text").GetComponent <Text>();
     trait1          = characterWindow.transform.Find("Trait 1").GetComponent <Text>();
     trait2          = characterWindow.transform.Find("Trait 2").GetComponent <Text>();
     trait3          = characterWindow.transform.Find("Trait 3").GetComponent <Text>();
     trait4          = characterWindow.transform.Find("Trait 4").GetComponent <Text>();
     characterName   = characterWindow.transform.Find("Character Name").GetComponent <Text>();
     characterRank   = characterWindow.transform.Find("Character Rank").GetComponent <Text>();
     characterImage  = characterWindow.transform.Find("Character Image").GetComponent <Image>();
     aView           = characterWindow.transform.Find("ScrollView").GetComponent <ActionScrollView>();
     rView           = characterWindow.transform.Find("Relations Scrollview").GetComponent <RelationsScrollView>();
     charRankImage   = characterWindow.transform.Find("Char Rank Image").GetComponent <Image>();
     rank1Image      = characterWindow.transform.Find("Rank 1 Image").GetComponent <Image>();
     rank2Image      = characterWindow.transform.Find("Rank 2 Image").GetComponent <Image>();
     characterWindow.SetActive(false); // sets the window as active initially
     blockingPanel.SetActive(false);   // this panel blocks mouse clicks from going 'through' the screen since it is supposed to be a modal screen
 }
Exemplo n.º 4
0
        public static House GetHouse(string hID)
        {
            //DataManager dManager = GameObject.Find("GameManager").GetComponent<DataManager>();
            GlobalGameData gameDataRef = GameObject.Find("GameManager").GetComponent <GlobalGameData>();

            return(gameDataRef.HouseList.Find(p => p.ID == hID));
        }
Exemplo n.º 5
0
    public static void DefineInputs()
    {
        ControllerData = new ControllerInputData();

        DigitalActionInput_Keyboard = new Dictionary <ControlAction, KeyCode>();
        DigitalActionValue_Keyboard = new Dictionary <ControlAction, KeyValue>();

        DigitalActionInput_Gamepad = new Dictionary <ControlAction, KeyCode>();
        DigitalActionValue_Gamepad = new Dictionary <ControlAction, KeyValue>();

        AnalogActionInput = new Dictionary <ControlAction, string>();
        AnalogActionValue = new Dictionary <ControlAction, float>();

        DefineKeyboardInputs();
        DefineGamepadInputs();

        AnalogActionInput[ControlAction.SPIN_AXIS] = GlobalGameData.GetAnalogActionSetting(ControlAction.SPIN_AXIS);
        AnalogActionInput[ControlAction.TURN_AXIS] = GlobalGameData.GetAnalogActionSetting(ControlAction.SPIN_AXIS);
        AnalogActionInput[ControlAction.FLIP_AXIS] = GlobalGameData.GetAnalogActionSetting(ControlAction.FLIP_AXIS);
        AnalogActionInput[ControlAction.SLOW_AXIS] = GlobalGameData.GetAnalogActionSetting(ControlAction.FLIP_AXIS);

        AnalogActionValue[ControlAction.SPIN_AXIS] = Constants.ZERO_F;
        AnalogActionValue[ControlAction.TURN_AXIS] = Constants.ZERO_F;
        AnalogActionValue[ControlAction.FLIP_AXIS] = Constants.ZERO_F;
        AnalogActionValue[ControlAction.SLOW_AXIS] = Constants.ZERO_F;
    }
Exemplo n.º 6
0
        public static List <Pops> GetCivPopList(string cID)
        {
            GlobalGameData gameDataRef = GameObject.Find("GameManager").GetComponent <GlobalGameData>();
            Civilization   civ         = gameDataRef.CivList.Find(p => p.ID == cID);

            return(civ.PopList);
        }
Exemplo n.º 7
0
    void Awake()
    {
        if (frame <= 0)
        {
            frame = 30;
        }

        //测试
        CPlayer cPlayer1 = new CPlayer
        {
            //ModelName = "child_01",
            //ModelPath = "",
            //Team = 0,
        };

        GlobalGameData.GetGlobalGameData().m_BattleData.m_UnitList.Add(cPlayer1);
        CPlayer cPlayer2 = new CPlayer
        {
            //ModelName = "child_01",
            //ModelPath = "",
            //Team = 1,
        };

        GlobalGameData.GetGlobalGameData().m_BattleData.m_UnitList.Add(cPlayer2);
        m_TurnBased = new TurnBased();
        m_FrameTime = 1 / frame;
    }
 void Awake()
 {
     gDataRef = GameObject.Find("GameManager").GetComponent<GlobalGameData>();
     graphicsDataRef = GameObject.Find("GameManager").GetComponent<GraphicAssets>(); // get graphics
     characterWindow = GameObject.Find("Character Window Panel");
     blockingPanel = GameObject.Find("Blocking Panel");
     age = characterWindow.transform.Find("Age Value").GetComponent<Text>();
     health = characterWindow.transform.Find("Health Value").GetComponent<Text>();
     wealth = characterWindow.transform.Find("Wealth Value").GetComponent<Text>();
     intelligence = characterWindow.transform.Find("Intelligence Value").GetComponent<Text>();
     influence = characterWindow.transform.Find("Influence Value").GetComponent<Text>();
     honor = characterWindow.transform.Find("Loyalty Value").GetComponent<Text>();
     intel = characterWindow.transform.Find("Intel Value").GetComponent<Text>();
     charm = characterWindow.transform.Find("Charisma Value").GetComponent<Text>();
     drive = characterWindow.transform.Find("Drive Value").GetComponent<Text>();
     piety = characterWindow.transform.Find("Piety Value").GetComponent<Text>();
     empathy = characterWindow.transform.Find("Empathy Value").GetComponent<Text>();
     passion = characterWindow.transform.Find("Will Value").GetComponent<Text>();
     history = characterWindow.transform.Find("History Text").GetComponent<Text>();
     CommText = characterWindow.transform.Find("Comm Text").GetComponent<Text>();
     trait1 = characterWindow.transform.Find("Trait 1").GetComponent<Text>();
     trait2 = characterWindow.transform.Find("Trait 2").GetComponent<Text>();
     trait3 = characterWindow.transform.Find("Trait 3").GetComponent<Text>();
     trait4 = characterWindow.transform.Find("Trait 4").GetComponent<Text>();
     characterName = characterWindow.transform.Find("Character Name").GetComponent<Text>();
     characterRank = characterWindow.transform.Find("Character Rank").GetComponent<Text>();
     characterImage = characterWindow.transform.Find("Character Image").GetComponent<Image>();
     aView = characterWindow.transform.Find("ScrollView").GetComponent<ActionScrollView>();
     rView = characterWindow.transform.Find("Relations Scrollview").GetComponent<RelationsScrollView>();
     charRankImage = characterWindow.transform.Find("Char Rank Image").GetComponent<Image>();
     rank1Image = characterWindow.transform.Find("Rank 1 Image").GetComponent<Image>();
     rank2Image = characterWindow.transform.Find("Rank 2 Image").GetComponent<Image>();
     characterWindow.SetActive(false); // sets the window as active initially
     blockingPanel.SetActive(false); // this panel blocks mouse clicks from going 'through' the screen since it is supposed to be a modal screen
 }
Exemplo n.º 9
0
 public SetupState(StateManager managerRef)
 {
     manager  = managerRef;
     gData    = GameObject.Find("GameManager").GetComponent <GalaxyData>();
     gameData = GameObject.Find("GameManager").GetComponent <GlobalGameData>();
     Debug.Log("In SetupState");
 }
Exemplo n.º 10
0
    public override void ExecuteMenuCommand()
    {
        GlobalInputController.LockInput();
        switch (MenuAction)
        {
        case MenuCommand.EXIT_GAME:
            Application.Quit();
            break;

        case MenuCommand.RESTART:
            SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex, LoadSceneMode.Single);
            break;

        case MenuCommand.CHANGE_SCENE:
            if (c_itemActiveData.i_nextScene > -1)
            {
                MessageServer.OnSceneChange();
                SceneManager.LoadScene(c_itemActiveData.i_nextScene, LoadSceneMode.Single);
            }
            break;

        case MenuCommand.RESUME:
            MessageServer.SendMessage(MessageID.PAUSE, new Message(0));
            break;

        case MenuCommand.MENU_BACK:
            MessageServer.SendMessage(MessageID.MENU_BACK, new Message());
            break;

        case MenuCommand.MENU_FORWARD:
            if (ChildMenuController == null)
            {
                return;
            }
            MessageServer.SendMessage(MessageID.MENU_FORWARD, new Message(ChildMenuController.GetSuperMenuIndex()));
            break;

        case MenuCommand.CONFIRM:
            break;

        case MenuCommand.EDIT_DATA:
            if (DataItem == DataTarget.ERROR_TARGET)
            {
                return;
            }
            if (ChildEditController == null)
            {
                return;
            }
            // open data editor, wait for return
            ChildEditController.Activate(DataItem);
            MessageServer.SendMessage(MessageID.EDIT_START, new Message());
            break;

        case MenuCommand.RESET_CONTROLS:
            GlobalGameData.SetControlsToDefault(DataItem == DataTarget.CONTROLLER_CONTROLS ? InputType.CONTROLLER_GENERIC : InputType.KEYBOARD_GENERIC);
            break;
        }
    }
Exemplo n.º 11
0
        public static Character GetCharacter(string cID)
        {
            GlobalGameData gameDataRef = GameObject.Find("GameManager").GetComponent <GlobalGameData>();
            Character      cData       = new Character();

            cData = gameDataRef.CharacterList.Find(p => p.ID == cID);
            return(cData);
        }
Exemplo n.º 12
0
    // Start is called before the first frame update
    void Start()
    {
        var globalGameDataGameObject = GameObject.FindGameObjectWithTag("GlobalData");

        globalGameData = globalGameDataGameObject.GetComponent <GlobalGameData>();

        image = GetComponent <RawImage>();
    }
 // Use this for initialization
 void Start()
 {
     gData = GameObject.Find("GameManager").GetComponent<GalaxyData>();
     gameData = GameObject.Find("GameManager").GetComponent<GlobalGameData>();
     planetsGenerated = GameObject.Find("Planets Generated").GetComponent<Text>();
     housesGenerated = GameObject.Find("Houses Generated").GetComponent<Text>();
     charactersGenerated = GameObject.Find("Characters Generated").GetComponent<Text>();
 }
Exemplo n.º 14
0
 //constructor
 public NewGameState(StateManager managerRef)
 {
     manager = managerRef;
     valuesLoaded = false; // reset
     valuesEntered = false;
     gameDataRef = GameObject.Find("GameManager").GetComponent<GlobalGameData>();
     Debug.Log("Constructing New Game Screen");
 }
Exemplo n.º 15
0
 public override void ConfirmDataEdit(DataTarget targetIn)
 {
     MessageServer.SendMessage(MessageID.EDIT_END, new Message());
     GlobalInputController.UpdateAction(InputAction, c_controllerData.k, this.InputType);
     GlobalGameData.SetActionSetting(InputAction, c_controllerData.k, this.InputType);
     MessageServer.SendMessage(MessageID.EDIT_DISPLAY_UPDATE, new Message((int)c_controllerData.k, (uint)InputAction).withInputType(this.InputType));
     Deactivate();
 }
Exemplo n.º 16
0
 private void Start()
 {
     InitializeCarts();
     InitializeData();
     InitializeStateMachine();
     c_controllerData.i = GlobalGameData.GetSettingsInt(CurrentTarget);
     ValueDisplay.text  = c_controllerData.i.ToString();
 }
Exemplo n.º 17
0
 private void Awake()
 {
     // Get game object components
     spriteRenderer = GetComponentInChildren <SpriteRenderer>();
     rigidBody      = GetComponent <Rigidbody2D>();
     character_anim = GetComponentInChildren <Animator>();
     globalData     = GameObject.FindGameObjectWithTag("GlobalData").GetComponent <GlobalGameData>();
 }
Exemplo n.º 18
0
    public void ChangeScene1()
    {
        SceneManager.LoadScene(0);
        //Debug.Log("name = " + PlayerPrefs.GetString("name"));

        PlayerPrefs.SetString("name", "tom");
        Debug.Log("name = " + GlobalGameData.GetGlobalGameData().m_UserData.name);
    }
Exemplo n.º 19
0
 public NewGameState(StateManager managerRef)   //constructor
 {
     manager       = managerRef;
     valuesLoaded  = false; // reset
     valuesEntered = false;
     gameDataRef   = GameObject.Find("GameManager").GetComponent <GlobalGameData>();
     Debug.Log("Constructing New Game Screen");
 }
Exemplo n.º 20
0
 public static GlobalGameData GetGlobalGameData()
 {
     if (self == null)
     {
         self = new GlobalGameData();
     }
     return(self);
 }
 // Use this for initialization
 void Start()
 {
     gData               = GameObject.Find("GameManager").GetComponent <GalaxyData>();
     gameData            = GameObject.Find("GameManager").GetComponent <GlobalGameData>();
     planetsGenerated    = GameObject.Find("Planets Generated").GetComponent <Text>();
     housesGenerated     = GameObject.Find("Houses Generated").GetComponent <Text>();
     charactersGenerated = GameObject.Find("Characters Generated").GetComponent <Text>();
 }
Exemplo n.º 22
0
    void Start()
    {
        // initialize state machine and managers
        activeState = new BeginState(this);
        galaxyDataRef = GetComponent<GalaxyData>();  // gets the galaxy data script containing the data structure
        gameDataRef = GetComponent<GlobalGameData>();  // gets global game data (screens, etc) that are used universally

        Debug.Log("This object is of type: " + activeState);
    }
Exemplo n.º 23
0
    void Start()
    {
        // initialize state machine and managers
        activeState   = new BeginState(this);
        galaxyDataRef = GetComponent <GalaxyData>();     // gets the galaxy data script containing the data structure
        gameDataRef   = GetComponent <GlobalGameData>(); // gets global game data (screens, etc) that are used universally

        Debug.Log("This object is of type: " + activeState);
    }
Exemplo n.º 24
0
    // Start is called before the first frame update
    void Start()
    {
        // Get global game data
        var globalGameDataGameObject = GameObject.FindGameObjectWithTag("GlobalData");

        globalGameData = globalGameDataGameObject.GetComponent <GlobalGameData>();

        sprite = GetComponent <SpriteRenderer>();
    }
Exemplo n.º 25
0
 public override void InitializeData()
 {
     c_controllerData = new EditControllerData();
     c_controllerData.b_editorActive = false;
     c_controllerData.k = GlobalGameData.GetActionSetting(InputAction, this.InputType);
     c_messageClient    = new InputEditMessageClient(this);
     MessageServer.Subscribe(ref c_messageClient, MessageID.EDIT_SWAP);
     MessageServer.Subscribe(ref c_messageClient, MessageID.EDIT_RESET);
 }
Exemplo n.º 26
0
 // Use this for initialization
 void Start()
 {
     mainC             = GameObject.Find("Main Camera").GetComponent <Camera>();
     gDataRef          = GameObject.Find("GameManager").GetComponent <GlobalGameData>();
     mainC.fieldOfView = maxZoomLevel;
     zoom               = mainC.fieldOfView;
     galaxyHeight       = gDataRef.GalaxySizeHeight;
     galaxyWidth        = gDataRef.GalaxySizeWidth;
     ScrollWheelIsValid = true;
 }
Exemplo n.º 27
0
    private void Awake()
    {
        GlobalGameData.CheckAndSetDefaults();

        GlobalInputController.InitializeInput();
        if (GlobalInputController.InputIsLocked())
        {
            StartCoroutine(GlobalInputController.StartLockTimer());
        }
    }
Exemplo n.º 28
0
    // Start is called before the first frame update
    void Start()
    {
        closeButton.SetActive(false);
        sweetSpot = GetSweetSpot();
        var audioSources = GetComponents <AudioSource>();

        globalData  = GameObject.FindGameObjectWithTag("GlobalData").GetComponent <GlobalGameData>();
        unlockSound = audioSources[0];
        wiggleSound = audioSources[1];
    }
Exemplo n.º 29
0
    public static void SaveSettings(float volumeLevel, float musicLevel)
    {
        string          slotPath  = "/config.globalxd";
        BinaryFormatter formatter = new BinaryFormatter();
        string          path      = Application.persistentDataPath + slotPath;
        FileStream      stream    = new FileStream(path, FileMode.Create);
        GlobalGameData  data      = new GlobalGameData(volumeLevel, musicLevel);

        formatter.Serialize(stream, data);
        stream.Close();
    }
Exemplo n.º 30
0
 // Use this for initialization
 public virtual void Start()
 {
     audioManager = FindObjectOfType <AudioManagerBehavior>();
     rb2          = GetComponent <Rigidbody2D>();
     ggd          = FindObjectOfType <GlobalGameData>();
     ground       = LayerMask.GetMask("Ground");
     feet         = transform.Find("feet").GetComponent <Collider2D>();
     shootyPoint  = transform.Find("shootyPoint");
     renderer     = transform.Find("sprite").GetComponent <SpriteRenderer>();
     anim         = GetComponent <Animator>();
 }
Exemplo n.º 31
0
 public static ModalPanel Instance()
 {
     if (!modalPanel)
     {
         gGameData = GameObject.Find("GameManager").GetComponent<GlobalGameData>();
         //modalPanel = new ModalPanel();
         modalPanel = FindObjectOfType(typeof(ModalPanel)) as ModalPanel;
         if (!modalPanel)
             Debug.LogError("There needs to be one active ModalPanel script on a GameObject in your scene.");
     }
     return modalPanel;
 }
Exemplo n.º 32
0
    public void InputUnbind()
    {
        c_controllerData.k = KeyCode.None;

        GlobalInputController.UpdateAction(InputAction, c_controllerData.k, this.InputType);
        GlobalGameData.SetActionSetting(InputAction, c_controllerData.k, this.InputType);

        if (InputSpriteController.getInputSprite(out spriteOut, c_controllerData.k, this.InputType))
        {
            SpriteDisplay.sprite = spriteOut;
        }
    }
Exemplo n.º 33
0
        public static StarData GetCivHomeSystem(Civilization civ)
        {
            GlobalGameData gameDataRef   = GameObject.Find("GameManager").GetComponent <GlobalGameData>();
            GalaxyData     galaxyDataRef = GameObject.Find("GameManager").GetComponent <GalaxyData>();
            PlanetData     pData         = new PlanetData();
            StarData       sData         = new StarData();

            pData = galaxyDataRef.GalaxyPlanetDataList.Find(p => p.ID == civ.CapitalPlanetID);
            sData = galaxyDataRef.GalaxyStarDataList.Find(p => p.ID == pData.SystemID);

            return(sData);
        }
Exemplo n.º 34
0
 void Start()
 {
     // data structure references
     gData       = GameObject.Find("GameManager").GetComponent <GalaxyData>();
     gameDataRef = GameObject.Find("GameManager").GetComponent <GlobalGameData>();
     //DataManager.PopulateObjectNameLists(); // populate the name lists once!
     galaxySizeWidth  = gameDataRef.GalaxySizeWidth; // these will be selected in new game screen
     galaxySizeHeight = gameDataRef.GalaxySizeHeight;
     GenerateNebulas();
     GenerateStars();
     GeneratePlanets();
 }
Exemplo n.º 35
0
    // TODO: swapping a key with pause will not also update the "other mutex" buttons, allowing for a multiple mapping edge case
    public void InputSwap(KeyCode keyIn)
    {
        c_controllerData.k = keyIn;

        GlobalInputController.UpdateAction(InputAction, c_controllerData.k, this.InputType);
        GlobalGameData.SetActionSetting(InputAction, c_controllerData.k, this.InputType);

        if (InputSpriteController.getInputSprite(out spriteOut, c_controllerData.k, this.InputType))
        {
            SpriteDisplay.sprite = spriteOut;
        }
        MessageServer.SendMessage(MessageID.EDIT_DISPLAY_UPDATE, new Message((int)c_controllerData.k, (uint)InputAction).withInputType(this.InputType));
    }
Exemplo n.º 36
0
        public static Civilization GetCivilization(string ID)
        {
            GlobalGameData gameDataRef = GameObject.Find("GameManager").GetComponent <GlobalGameData>();

            if (gameDataRef.CivList.Exists(p => p.ID == ID))
            {
                return(gameDataRef.CivList.Find(p => p.ID == ID));
            }
            else
            {
                return(null);
            }
        }
 // Use this for initialization
 void Start()
 {
     mainC = GameObject.Find("Main Camera").GetComponent<Camera>();
     gDataRef = GameObject.Find("GameManager").GetComponent<GlobalGameData>();
     mainC.fieldOfView = maxZoomLevel;
     zoom = mainC.fieldOfView;
     galaxyHeight = gDataRef.GalaxySizeHeight;
     galaxyWidth = gDataRef.GalaxySizeWidth;
     ScrollWheelIsValid = true;
 }
Exemplo n.º 38
0
 void Start()
 {
     gData = GameObject.Find("GameManager").GetComponent<GalaxyData>();
     gameDataRef = GameObject.Find("GameManager").GetComponent<GlobalGameData>();
     // now generate civilizations
     GenerateHumanCiv();
     GenerateAICivs();
     GenerateCommonHouses(); // generate houses
     GenerateHouseStats(); // generate the other house status
     GenerateCharacters(); // generate characters for the global pool
     GenerateCivLeaders();
     AssignHouses(); // assign houses
     GenerateRelationships(); // determine everyone's relationship to everyone else
     GenerateProvinces(); // generate provinces for each civilization
     DetermineSystemCapitals();
     GenerateStellarObjectLeaders(); // test; put back after generate primes if needed
     GenerateInfrastructure();
     SetPlanetTaxes();
     GeneratePrimes();
     GeneratePlanetIntelLevels(gameDataRef.CivList.Find(p => p.HumanCiv == true));
     gameDataRef.CivsGenerated = true; // sends flag to move to the galaxy screen
 }
Exemplo n.º 39
0
 void Awake()
 {
     tileMapPanel = GameObject.Find("Tile Map Panel");
     stellarographyPanel = GameObject.Find("Stellarography Panel");
     industryDisplayButton = GameObject.Find("Industry Display Button");
     economicDisplayButton = GameObject.Find("Economic Display Button");
     graphicsDataRef = GameObject.Find("GameManager").GetComponent<GraphicAssets>();
     intelLevelText = GameObject.Find("Intel Level Text Label").GetComponent<Text>();
     intelLevelValue = GameObject.Find("Intel Level").GetComponent<Text>();
     planetValueText = GameObject.Find("Planet Value Label").GetComponent<Text>();
     planetValue = GameObject.Find("Planet Value").GetComponent<Text>();
     starbaseText = GameObject.Find("Starbase Level Label").GetComponent<Text>();
     starbaseValue = GameObject.Find("Starbase Level").GetComponent<Text>();
     starbaseDataPanel = GameObject.Find("Starbase Data Panel").GetComponent<Image>();
     tradeHubIndicator = GameObject.Find("Trade Hub Indicator").GetComponent<Text>();
     throughputRemaining = GameObject.Find("Capacity Remaining").GetComponent<Text>();
     tileMapLight = GameObject.Find("Region UI Light").GetComponent<Light>();
     edictPanel = GameObject.Find("Edict Panel");
     wireFrameOverlay = GameObject.Find("Wireframe Planet Overlay");
     planetButtonBarBackground = GameObject.Find("Planet Button Bar Background");
     gameDataRef = GameObject.Find("GameManager").GetComponent<GlobalGameData>();
     planetCanvas = GameObject.Find("Planet UI Canvas").GetComponent<Canvas>();
     //viceroyImageTop = GameObject.Find("Character Image").GetComponent<Image>();
 }
    private static bool DoesBuildFocusChange(PlanetData pData, Character vic, GlobalGameData gDataRef)
    {
        float timeSinceChange = vic.TimeSinceBuildFocusChange;
        float changeChance = 0;

        if (vic.Traits.Exists(p => p.Name == "Erratic"))
        {
            changeChance += 20f;
        }

        changeChance -= (vic.GoalStabilityTendency / 10f);
        changeChance += timeSinceChange * 10f;

        // if there are critical shortfalls on planets, vics are much less likely to change their focus
        if (vic.BuildFocus == Character.eBuildFocus.Farms)
        {
            if (pData.FoodDifference > 0)
            {
                changeChance -= pData.FoodDifference;
            }
        }

        if (vic.BuildFocus == Character.eBuildFocus.Hightech)
        {
            if (pData.EnergyDifference > 0)
            {
                changeChance -= pData.EnergyDifference;
            }
        }

        if (changeChance > 80)
        {
            return true; // yes, the focus changes
        }

        return false;
    }
    // this 'flags' planets to seed with pops in the next step
    public static void ClaimPlanetsForCiv(Civilization newCiv)
    {
        gameDataRef = GameObject.Find("GameManager").GetComponent<GlobalGameData>();
        galaxyDataRef = GameObject.Find("GameManager").GetComponent<GalaxyData>();

        float civMaxDistance = newCiv.Range;
        PlanetData homePlanet = galaxyDataRef.GalaxyPlanetDataList.Find(p => p.ID == newCiv.CapitalPlanetID);
        StarData homeStar = galaxyDataRef.GalaxyStarDataList.Find(p => p.ID == homePlanet.SystemID);

        List<StarData> eligibleSystems = new List<StarData>();
        foreach (StarData star in galaxyDataRef.GalaxyStarDataList)
        {
            float distance = HelperFunctions.Formulas.MeasureDistanceBetweenSystems(star, homeStar);
            if ( distance <= civMaxDistance) // must be within range and also include the home system
                eligibleSystems.Add(star); // add systems that are close to the home star
        }

        //
        // now check planets in those systems to see if they can be owned
        foreach (StarData potStar in eligibleSystems)
        {
            foreach(PlanetData pData in potStar.PlanetList)
            {
                if (pData.AdjustedBio >= newCiv.PlanetMinTolerance)
                {
                    bool planetEligible = true;
                    foreach (Civilization civ in gameDataRef.CivList) // check each civ to make sure they don't own the planet
                    {
                        if (civ.PlanetIDList.Exists (p => p == pData.ID))
                            planetEligible = false;
                        if (pData.ID == homePlanet.ID)
                            planetEligible = false;
                        if (pData.AdjustedMaxHabitableTiles == 0) // if after traits there are no tiles to put people on, it's not a good planet!
                            planetEligible = false;
                    }
                    if (planetEligible) // if they don't, then claim!
                        ClaimCivPlanet(pData,newCiv);
                }
            }
        }
    }
    public static Civilization CreateNewCivilization()
    {
        List<String> civNameList = DataManager.civNameList;
        // populate the color list if needed
        if (civColorList.Count == 0)
            PopulateCivColorList();

        Civilization newCiv = new Civilization();
        int dieRoll = 0;
        galaxyDataRef = GameObject.Find("GameManager").GetComponent<GalaxyData>(); // access galaxy data
        gameDataRef = GameObject.Find("GameManager").GetComponent<GlobalGameData>(); // access galaxy data

        // Step 1: Generate type of civ
        dieRoll = UnityEngine.Random.Range(1, 7);
        newCiv.Type = (Civilization.eCivType)dieRoll;  // cast to enum

        // Step 2: Generate ID of civ
        newCiv.ID = "CIV" + gameDataRef.CivList.Count.ToString("N0");

        // Step 2: Generate name of civ
        string primaryName = "";
        string surName = "";

        if (civNameList.Count > 0)
        {
            var nameIndex = UnityEngine.Random.Range(0, civNameList.Count);
            primaryName = civNameList[nameIndex];
            civNameList.RemoveAt(nameIndex);
            civNameList.TrimExcess();
        }
        else
            primaryName = "GenericName";

        var surNameIndex = UnityEngine.Random.Range(0, DataManager.civSurNameList.Count);
        surName = DataManager.civSurNameList[surNameIndex];

        newCiv.Name = primaryName + " " + surName;

        // Step 3: Generate other base stats (treasury, size, etc)

        // size/range
        newCiv.Range = 40; // to start with
        int size = UnityEngine.Random.Range(0, 100);

        // adjust size/other ratings for civ type
        switch(newCiv.Type)
        {
            case Civilization.eCivType.Confederation :
                {
                    size += 55;
                    break;
                }
            case Civilization.eCivType.MinorEmpire:
                {
                    size += 40;
                    break;
                }
            case Civilization.eCivType.Satrapy:
                {
                    size += 20;
                    break;
                }
            case Civilization.eCivType.BrokenCivilization:
                {
                    size -= 30;
                    break;
                }
            case Civilization.eCivType.Pirates:
                {
                    size -= 15;
                    break;
                }
        }

        // add a empire type mod here
        if (size < 40)
            newCiv.Size = Civilization.eCivSize.SinglePlanet;
        else if (size < 70)
            newCiv.Size = Civilization.eCivSize.Local;
        else if (size < 90)
        {
            newCiv.Size = Civilization.eCivSize.Minor;
            newCiv.Range = UnityEngine.Random.Range(MultiSystemEmpireRange - 200, MultiSystemEmpireRange + 200);
        }
        else
        {
            newCiv.Size = Civilization.eCivSize.Major;
            newCiv.Range = UnityEngine.Random.Range(MultiRegionEmpireRange - 400, MultiRegionEmpireRange + 400);
        }

        // skill ratings
        newCiv.FarmingBaseRating = UnityEngine.Random.Range(70, 100) - (int)newCiv.Type * 10;
        newCiv.MiningBaseRating = UnityEngine.Random.Range(50, 90) - (int)newCiv.Type * 10;
        newCiv.ScienceBaseRating = UnityEngine.Random.Range(0, 50) + (int)newCiv.Type * 10;
        newCiv.HighTechBaseRating = UnityEngine.Random.Range(0, 40) + (int)newCiv.Type * 10;
        newCiv.ManufacturingBaseRating = UnityEngine.Random.Range(5, 50) + (int)newCiv.Type * 10;

        // tolerance
        newCiv.PlanetMinTolerance = UnityEngine.Random.Range(40, 60); // sets the base minimum habitable world a civilization is willing to tolerate

        // province size
        if (newCiv.Size == Civilization.eCivSize.Major)
        {
            newCiv.CivMaxProvinceSize = UnityEngine.Random.Range(1, 6); // sets a province size between 1 and 5 systems
            newCiv.AdminRating = UnityEngine.Random.Range(5, 21); // generates the civ's base admin rating (how efficient they are in adminstering provinces
        }
        else
        {
            newCiv.CivMaxProvinceSize = 0; // no provinces can be created; the civ is essentially one province
            newCiv.AdminRating = 1;
        }

        // admin rating

        // Step 4: Determine planet of origin
        retryPlanet: // beginning of retry loop
        PlanetData civPlanet = new PlanetData();

        dieRoll = UnityEngine.Random.Range(0, galaxyDataRef.GalaxyPlanetDataList.Count); // find the planets in the quadrant
        civPlanet = galaxyDataRef.GalaxyPlanetDataList[dieRoll];

        if (galaxyDataRef.GalaxyPlanetDataList[dieRoll].AdjustedBio < newCiv.PlanetMinTolerance) // if the bio is too low, throw it out
            goto retryPlanet;

        if (gameDataRef.CivList.Count > 0)
        {
            foreach (Civilization civ in gameDataRef.CivList)
            {
                List<StarData> populatedHomeSystems = new List<StarData>();
                populatedHomeSystems = HelperFunctions.DataRetrivalFunctions.GetCivSystemList(civ);

                if (civPlanet.ID == civ.CapitalPlanetID)  // check for capital world
                    goto retryPlanet;
                if (civ.PlanetIDList.Exists(p => p == civPlanet.ID)) // then all other worlds
                    goto retryPlanet;
                if (newCiv.ID != civ.ID)
                    if (populatedHomeSystems.Exists(p => p.ID == civPlanet.SystemID)) // check for systems that other civs have claimed
                        goto retryPlanet;
            }

            // assign a name for the civ's planet
            if (DataManager.planetNameList.Count > 0)
            {
                var nameIndex = UnityEngine.Random.Range(0, DataManager.planetNameList.Count);
                civPlanet.Name = DataManager.planetNameList[nameIndex];
                DataManager.planetNameList.RemoveAt(nameIndex);
                DataManager.planetNameList.TrimExcess();
            }
            else
                civPlanet.Name = "GenericName";

            // set as capital and send to assign pops, developments, etc.
            newCiv.CapitalPlanetID = civPlanet.ID;
            ClaimCivPlanet(civPlanet, newCiv);
            civPlanet.Rank = PlanetData.ePlanetRank.ImperialCapital;
            newCiv.PlanetIDList.Add(civPlanet.ID); // add the planet
        }

        // Step 5: Determine additional planets
        if (newCiv.Size != Civilization.eCivSize.SinglePlanet)
            ClaimPlanetsForCiv(newCiv);

        // Step 5: Generate color of civ
        retryColor: // beginning of retry loop
        Color civColor = new Color();

        civColor = new Color(UnityEngine.Random.Range(.01f, .99f), UnityEngine.Random.Range(.01f, .99f), UnityEngine.Random.Range(.01f, .99f)); // select a random color
        if (gameDataRef.CivList.Count > 0)
        {
            foreach (Civilization civ in gameDataRef.CivList)
            {
                if (civColor == civ.Color)
                    goto retryColor;
            }
            newCiv.Color = civColor;
        }

        return newCiv;
    }
    public static void GenerateNebula()
    {
        NebulaData nData = new NebulaData();
        galaxyDataRef = GameObject.Find("GameManager").GetComponent<GalaxyData>();
        gameDataRef = GameObject.Find("GameManager").GetComponent<GlobalGameData>();

        // Step 1: Generate name
        if (DataManager.planetNameList.Count > 0)
        {
            var nameIndex = UnityEngine.Random.Range(0, DataManager.planetNameList.Count);
            nData.Name = DataManager.planetNameList[nameIndex] + " Nebula";
            DataManager.planetNameList.RemoveAt(nameIndex);
            DataManager.planetNameList.TrimExcess();
        }
        else
            nData.Name = "GenericName";

        // Step 2: Set location
        nData.WorldLocation = new Vector3(UnityEngine.Random.Range(-gameDataRef.GalaxySizeWidth,gameDataRef.GalaxySizeWidth), UnityEngine.Random.Range(-gameDataRef.GalaxySizeHeight, gameDataRef.GalaxySizeHeight), UnityEngine.Random.Range(-25,-75)); // set slightly back of X axis for parallax effect

        // Step 3: Assign sprite #
        nData.NebulaSpriteNumber = UnityEngine.Random.Range(0, SpritesPerNebulaType - 1);

        // Step 4: Generate size
        nData.NebulaSize = UnityEngine.Random.Range(.5f, 1.5f);

        // Step 5: Assign rotation
        switch (nData.NebulaSpriteNumber)
        {
            case 0:
            {
                nData.TextRotation = -55f;
                break;
            }
            case 1:
            {
                nData.TextRotation = -55f;
                break;
            }
            case 2:
            {
                nData.TextRotation = 45f;
                break;
            }
            case 3:
            {
                nData.TextRotation = -55f;
                break;
            }
            case 4:
            {
                nData.TextRotation = -60f;
                break;
            }
            default:
            {
                nData.TextRotation = 0f;
                break;
            }
        }

        // Step 6: Assign the data
        galaxyDataRef.AddStellarPhenonomaDataToList(nData);
    }
 void Awake()
 {
     uiCanvas = GameObject.Find("Character Window Canvas").GetComponent<Canvas>();
     graphicDataRef = GameObject.Find("GameManager").GetComponent<GraphicAssets>();
     gDataRef = GameObject.Find("GameManager").GetComponent<GlobalGameData>();
 }
Exemplo n.º 45
0
 void Start()
 {
     // data structure references
     gData = GameObject.Find("GameManager").GetComponent<GalaxyData>();
     gameDataRef = GameObject.Find("GameManager").GetComponent<GlobalGameData>();
     //DataManager.PopulateObjectNameLists(); // populate the name lists once!
     galaxySizeWidth = gameDataRef.GalaxySizeWidth; // these will be selected in new game screen
     galaxySizeHeight = gameDataRef.GalaxySizeHeight;
     GenerateNebulas();
     GenerateStars();
     GeneratePlanets();
 }
Exemplo n.º 46
0
 void Awake()
 {
     gameDataRef = GameObject.Find("GameManager").GetComponent<GlobalGameData>();
     graphicsDataRef = GameObject.Find("GameManager").GetComponent<GraphicAssets>();
 }
 void Awake()
 {
     gDataRef = GameObject.Find("GameManager").GetComponent<GlobalGameData>();
     cScreen = GameObject.Find("Character Window Canvas").GetComponent<CharacterScreen>();
 }
Exemplo n.º 48
0
 void Awake()
 {
     gGameDataRef = GameObject.Find("GameManager").GetComponent<GlobalGameData>(); // tie the game camera script to the data
 }
 void Awake()
 {
     gameDataRef = GameObject.Find("GameManager").GetComponent<GlobalGameData>();
 }
Exemplo n.º 50
0
    // Use this for initialization
    void Start()
    {
        galDataRef = GameObject.Find("GameManager").GetComponent<GalaxyData>();
        gDataRef = GameObject.Find("GameManager").GetComponent<GlobalGameData>();

        // run 4 times before first turn to maximize
        for (int x = 0; x < 4; x++)
        {
            foreach (Civilization civ in gDataRef.CivList)
            {
                UpdatePlanets(civ);
                CheckForMigration(civ); // check for intraplanet migration
                MigratePopsBetweenPlanets(civ); // and if there are any pops who want to leave, check for where
            }
        }
        UpdateTrades();
        UpdateEmperor();
        gDataRef.UpdateGameDate();
        gDataRef.RequestGraphicRefresh = true;
    }
Exemplo n.º 51
0
        void Awake()
        {
            // modal stuff
            modalPanel = ModalPanel.Instance();  // sets up a static instance of the window
            myYesAction = new UnityAction(TestYesFunction); // assign functions to actions
            myNoAction = new UnityAction(TestNoFunction);
            myCancelAction = new UnityAction(TestCancelFunction);

            starmapSprite = GameObject.Find("Y-Axis Grid");
            systemHeaderImage = GameObject.Find("System Header Image");
            starDataTextLine = GameObject.Find("StarDataTextInfo").GetComponent<Text>();
            secondaryDataTextLine = GameObject.Find("CameraZoomValue").GetComponent<Text>();
            secondaryZoomValueLine = GameObject.Find("CameraZoomInfo").GetComponent<Text>();
            gameDate = GameObject.Find("GameDate").GetComponent<Text>();
            backingSphere = GameObject.Find("Backing Sphere");
            empireTreasuryRevenues = GameObject.Find("EmpireTreasuryRevenues").GetComponent<Text>();
            empireTreasuryExpenses = GameObject.Find("EmpireTreasuryExpenses").GetComponent<Text>();
            emperorPoSup = GameObject.Find("Popular Support").GetComponent<Text>();
            emperorAP = GameObject.Find("Action Points").GetComponent<Text>();
            emperorBenevolentInfluence = GameObject.Find("Benevolent Influence").GetComponent<Text>();
            emperorPragmaticInfluence = GameObject.Find("Pragmatic Influence").GetComponent<Text>();
            emperorTyrannicalInfluence = GameObject.Find("Tyrannical Influence").GetComponent<Text>();
            versionNumber = GameObject.Find("Version Info").GetComponent<Text>();
            systemUICanvas = GameObject.Find("System UI Canvas");
            eventScrollView = GameObject.Find("Event ScrollView");
            selectedUnitInfoCanvas = GameObject.Find("Selected Unit Information Canvas");
            systemDisplaySystemName = GameObject.Find("System Name Text").GetComponent<Text>();
            systemDisplaySecondaryDataLine = GameObject.Find("Secondary Header Line").GetComponent<Text>();
            systemDisplayTertiaryDataLine = GameObject.Find("Tertiary Header Line").GetComponent<Text>();
            galaxyMapModeInfo = GameObject.Find("MapModeInfo").GetComponent<Text>();
            galaxyMapSubModeInfo = GameObject.Find("MapSubModeInfo").GetComponent<Text>();
            empireStatusBar = GameObject.Find("Empire Status Bar").GetComponent<Image>();
            button = GameObject.Find("War Button").GetComponent<Image>();
            galaxyUICanvas = GameObject.Find("Galaxy UI Canvas").GetComponent<Canvas>();
            galaxyPlanetInfoCanvas = GameObject.Find("Galaxy Planet Info Canvas").GetComponent<Canvas>();
            eventPanelButton = GameObject.Find("Event Panel Button");

            // data objects
            gameDataRef = GameObject.Find("GameManager").GetComponent<GlobalGameData>(); // get global game data (date, location, version, etc)
            gCameraRef = GameObject.Find("Main Camera").GetComponent<GalaxyCameraScript>(); // get global camera script

            if (!starDataTextLine)
            {
                Debug.LogError("This script requires a text object!");
                enabled = false;
                return;
            }
        }