Example #1
0
 void Start()
 {
     Physics2D.gravity = Vector3.zero;
     gv = GameObject.Find("GameVariables").GetComponent<GameVariables>();
     asource = GameObject.Find("GameVariables").GetComponent<AudioSource>();
     //kh = GameObject.FindGameObjectWithTag("knight").GetComponent<KnightsHealth>();
     //rb2d = GetComponent<Rigidbody2D>();
     StartCoroutine(DestroySelf());
 }
    /// <summary> 
    /// Load win line definition from xml file.
    /// </summary>
    public void LoadLinesDefinition(GameVariables.GAME_DEFINE _gd)
    {
        GameVariables.Instance.winLineData.Clear ();

        string strXmlContent = "";
        string strLineDefFileName;
        if (_gd == GameVariables.GAME_DEFINE.THREE_X_FIVE)
            strLineDefFileName = "/StreamingAssets/Xml/3x5_lines_definition.xml";//  + (GameVariables.NUM_OF_ROWS -1) + "x" + GameVariables.Instance.NUM_OF_COLS + "_lines_definition";
        else
            strLineDefFileName = "/StreamingAssets/Xml/4x5_lines_definition.xml";

        string filePath = Application.dataPath + strLineDefFileName;

        string textAsset = System.IO.File.ReadAllText (filePath);

        //TextAsset textAsset = (TextAsset)Resources.Load(strLineDefFileName, typeof(TextAsset));

        if (textAsset == null)
        {
            Debug.Log("'lines_definition.xml' not found or not readable");
        }
        else
        {
            XMLNode lineDefinitionXML = m_XMLparser.Parse(textAsset);

            int winIndex = 0;

            for (int i=0; i<GameVariables.NUM_OF_LINES; i++)
            {
                int[] wl = new int[GameVariables.Instance.NUM_OF_COLS];
                for (int j=0; j<GameVariables.Instance.NUM_OF_COLS; j++)
                {

                    strXmlContent = lineDefinitionXML.GetValue("LinesDefinition>0>Line_"+(i+1)+">0>Reel_"+(j+1)+">0>_text");

                    string[] strSplitContent = strXmlContent.Split(',');

                    for (int k=0; k< GameVariables.Instance.NUM_OF_ROWS -1; k++)
                    {
                        if (int.Parse(strSplitContent[k]) > 0)
                        {
                            winIndex = j * GameVariables.Instance.NUM_OF_ROWS + k + 1;
                            wl[j] = winIndex;
                            break;
                        }

                    }

                }

                GameVariables.Instance.winLineData.Add(wl);

            }
        }
    }
Example #3
0
 void Awake()
 {
     if(gVar == null)
     {
         DontDestroyOnLoad(gameObject);
         gVar = this;
     }
     else if (gVar != this)
     {
         Destroy(gameObject);
     }
 }
 internal void RoomJoin <T>(string gameMode, string maxPlayers, string roomCode, string entryFee, Action <T> successResponse = null, Action <string, string> errorResponse = null) where T : ResponseData
 {
     payloadKeyValuePairs.Clear();
     payloadKeyValuePairs.Add(GameConstants.USER_ID, GameVariables.userId);
     payloadKeyValuePairs.Add(GameConstants.ACCESS_TOKEN, GameVariables.AccessToken);
     payloadKeyValuePairs.Add(GameConstants.IS_PRACTICE, ((short)GameVariables.currentUserMode).ToString());
     payloadKeyValuePairs.Add(GameConstants.GAME_MODE, gameMode);
     payloadKeyValuePairs.Add(GameConstants.MAX_PLAYERS, maxPlayers);
     payloadKeyValuePairs.Add(GameConstants.ROOM_CODE, roomCode);
     payloadKeyValuePairs.Add(GameConstants.ENTRY_FEE, entryFee);
     _ = StartCoroutine(RESTApiService.UnityWebRequestInPostMethod(GameVariables.GetRestApiUrl(GameVariables.RESTApiType.roomJoin),
                                                                   payloadKeyValuePairs, successResponse, errorResponse));
 }
Example #5
0
    public override void PreInitialize()
    {
        base.PreInitialize();
        this.placingObjectManager = PlacingObjectManager.Instance;
        this.gridManager          = GridManager.Instance;
        this.towerManager         = TowerManager.Instance;
        this.trapManager          = TrapManager.Instance;
        this.timeManager          = TimeManager.Instance;
        this.gameVariables        = GameVariables.instance;
        this.mapInfoPck           = MapInfoPck.Instance;

        this.placingObjectManager.PreInitialize();
    }
    // Use this for initialization
    void Start()
    {
        GameVariables.UserPrefToVariables();

        volM = GameObject.Find("Slider_musique");
        volM.GetComponent <Slider>().value = GameVariables.volMusic; //GameVariables.VolumeToSliderValue(GameVariables.volMusic);

        volS = GameObject.Find("Slider_son");
        volS.GetComponent <Slider>().value = GameVariables.volSound;  //GameVariables.VolumeToSliderValue(GameVariables.volSound);

        help = GameObject.Find("Toggle_aide");
        help.GetComponent <Toggle>().isOn = GameVariables.help;
    }
Example #7
0
    public GameMaster()
    {
        Bytes     = new Interpreter(this);
        Cards     = new CardManager();
        Functions = new GameFunctions();
        Players   = new PlayerManager(4);
        Variables = new GameVariables();

        // change this outside of testing
        UI = new DummyUI();

        queryCheck = QueryBeforeRead;
    }
Example #8
0
    void Awake()
    {
        isTutorialOver = PlayerPrefs.GetInt("Tutorial", 0) == 1 ? true : false;
        gameVariables  = GameVariables.Instance;
        gameVariables.Init();
        ball.sprite = balls [Shop.Instance.currentBall];
        Color startColor = trailcolors [Shop.Instance.currentBall];
        Color endColor   = trailcolors [Shop.Instance.currentBall];

        startColor.a         = 0.5f;
        endColor.a           = 0f;
        ballTrail.startColor = startColor;
        ballTrail.endColor   = endColor;
        instance             = this;
    }
Example #9
0
 //Awakakake
 private void Awake()
 {
     if (gameVariables == null)
     {
         gameVariables = this;
         DontDestroyOnLoad(gameObject);
     }
     else
     {
         if (gameVariables != this)
         {
             Destroy(gameObject);
         }
     }
 }
 private void Start()
 {
     variablesScript            = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameVariables>();
     inputManager               = GameObject.FindGameObjectWithTag("InputManager");
     InputScript                = inputManager.GetComponent <MouseInput>();
     soldierCounter             = GameObject.FindGameObjectWithTag("SoldierCounter");
     soldierCounterScript       = soldierCounter.GetComponent <SoldierCounter>();
     soldierOneTargetPosition   = new Vector3(-302, 230, 0);
     soldierTwoTargetPosition   = new Vector3(-67, 183, 0);
     soldierThreeTargetPosition = new Vector3(344, -6, 0);
     if (variablesScript.inTutorial)
     {
         tutScript = GameObject.FindGameObjectWithTag("TutorialManager").GetComponent <TutorialManager>();
     }
     soldierPositions = GameObject.FindGameObjectsWithTag("SoldierPlaceholder");
 }
Example #11
0
    void Awake()
    {
        if (gemsPrefabs == null || gemsPrefabs.Count < 5)
        {
            Debug.Log("Warning not enough prefabs set");
        }


        if (SceneManager.GetActiveScene().name == "FacebookGameScene" || SceneManager.GetActiveScene().name == "FreeplayGameScene")
        {
            gemClick = GemClicked;
            gemDeath = CreateNewGem;
            gameVars = gameObject.GetComponent <GameVariables>();
        }

        doUpdateStuff = null;
    }
Example #12
0
    void Start()
    {
        Physics2D.gravity = Vector3.zero;
        gd = GameObject.Find("Difficulty").GetComponent <StoreDifficulty>();
        gv = GameObject.Find("GameVariables").GetComponent <GameVariables>();

        switch (gd.gameDifficulty)
        {
        case 1:
        {
            numGold  = 75;
            gv.horde = 75;
            break;
        }

        case 2:
        {
            numGold  = 50;
            gv.horde = 50;
            break;
        }

        case 3:
        {
            numGold  = 25;
            gv.horde = 25;
            break;
        }

        case 4:
        {
            numGold  = 10;
            gv.horde = 10;
            break;
        }
        }

        for (int x = 0; x < numGold; x++)
        {
            randomNumberX = Random.Range(-5f, -4f);
            randomNumberY = Random.Range(-3f, 3f);

            gv.goldList.Add(gold);
            Instantiate(gold, new Vector3(randomNumberX, randomNumberY, 0), Quaternion.identity);
        }
    }
 void OnTriggerEnter2D(Collider2D col)
 {
     if (col.gameObject.layer == LayerMask.NameToLayer("Button"))
     {
         col.GetComponent <ButtonController>().Trigger();
         if (GameVariables.HasWon())
         {
             victoryText.SetActive(true);
             IEnumerator coroutine = WaitAndTurnOffVictory();
             StartCoroutine(coroutine);
         }
     }
     else if (col.gameObject.layer == LayerMask.NameToLayer("Fire"))
     {
         Reset();
     }
 }
Example #14
0
        public void NewWorld()
        {
            // Note that the properties should be defined in this order due to how they reference each other
            GameVariables.NewWorld(this);
            EgLocations.NewWorld(this);
            EgCharacters.NewWorld(this);
            EgItems.NewWorld(this);

            GrainClusterClient.Universe.SetGameIntroductionText("There once was an example game.");
            GrainClusterClient.Universe.SetCustom(this).Wait();

            GrainClusterClient.Universe.AddGameCommand(new DanceCommand());

            // TODO: From the cemetary theatre you'll need to set the numbers on a combination lock to 1234 through the use command.
            // TODO: When a new game starts the combination should be initially set to 8734.
            // TODO: getting the combination right should lead to the warped hall
        }
Example #15
0
    // Awake is always called before any Start functions
    void Awake()
    {
        // check there is only one instance of this and that it is not destroyed on load
        if (Instance == null)
        {
            Instance = this;
        }
        else if (Instance != this)
        {
            Destroy(gameObject);
        }
        DontDestroyOnLoad(gameObject);

        // Initialize game variables
        _gameVariables = this.GetComponent <GameVariables> ();
        _gameVariables.Initialize();
    }
    private void Start()
    {
        inputManagerObject = GameObject.FindGameObjectWithTag("InputManager");
        variablesScript    = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameVariables>();
        InputScript        = inputManagerObject.GetComponent <MouseInput>();
        riskMeterUI.SetMaxRisk(maxRisk);
        riskMeterUI.setRisk(startingRisk);
        currentRisk = startingRisk;
        currentTime = startingTime;

        if (variablesScript.inTutorial)
        {
            riskSpeed = 5;
        }
        else if (!variablesScript.inTutorial)
        {
            riskSpeed = 10;
        }
    }
Example #17
0
    public void UpdateFlagsText(GameVariables variables)
    {
        string newText = "";

        foreach (string str in variables.GetFlags())
        {
            newText += str + "\n";
        }
        foreach (KeyValuePair <string, string> kvp in variables.GetVariables())
        {
            newText += kvp.Key + ": " + kvp.Value + "\n";
        }
        foreach (KeyValuePair <string, int> kvp in variables.GetCounters())
        {
            newText += kvp.Key + ": " + kvp.Value + "\n";
        }

        flagsText.text = newText;
    }
Example #18
0
    void Start()
    {
        Physics2D.gravity = Vector3.zero;
        gd = GameObject.Find("Difficulty").GetComponent<StoreDifficulty>();
        gv = GameObject.Find("GameVariables").GetComponent<GameVariables>();

        switch(gd.gameDifficulty)
        {
            case 1:
            {
                numGold = 75;
                gv.horde = 75;
                break;
            }
            case 2:
            {
                numGold = 50;
                gv.horde = 50;
                break;
            }
            case 3:
            {
                numGold = 25;
                gv.horde = 25;
                break;
            }
            case 4:
            {
                numGold = 10;
                gv.horde = 10;
                break;
            }
        }

        for(int x=0;x<numGold;x++)
        {
            randomNumberX = Random.Range(-5f,-4f);
            randomNumberY = Random.Range(-3f,3f);

            gv.goldList.Add(gold);
            Instantiate(gold,new Vector3(randomNumberX,randomNumberY,0),Quaternion.identity);
        }
    }
Example #19
0
    void Start()
    {
        playerHitSound  = Resources.Load <AudioClip>("PlayerHit");
        shootSound      = Resources.Load <AudioClip>("ArrowShot");
        bossAttack      = Resources.Load <AudioClip>("BossAttack");
        bossDeath       = Resources.Load <AudioClip>("BossDeath");
        BossRoar        = Resources.Load <AudioClip>("BossRoar");
        DungeonMusic    = Resources.Load <AudioClip>("DungeonMusic");
        enemyDeathSound = Resources.Load <AudioClip>("GoblinDeath");
        goblinSlash     = Resources.Load <AudioClip>("GoblinSlash");
        DefeatSound     = Resources.Load <AudioClip>("LostSound");
        MainMusic       = Resources.Load <AudioClip>("MenuMusic");
        pickUpSound     = Resources.Load <AudioClip>("PickUp");
        slashSound      = Resources.Load <AudioClip>("SwordSlash");
        TownMusic       = Resources.Load <AudioClip>("TownMusic");

        audioSrc        = GetComponent <AudioSource>();
        audioSrc.volume = GameVariables.getVolume();
    }
    //Milicia
    void addFirstFoundHabitantForType(Batiment.role type)
    {
        if (GameVariables.listHabitant.Count == 0 && GameVariables.batimentSelectionne.ListHabitants.Count < GameVariables.batimentSelectionne.nbrMaxHab)
        {
            return;
        }


        Batiment batiment = null;

        foreach (Batiment bat in GameVariables.listBatiment)
        {
            if (!bat.isEnDeplacement() && bat.typeHabitant == type && bat.ListHabitants.Count < bat.nbrMaxHab)
            {
                batiment = bat;
                break;
            }
        }

        if (batiment == null || batiment.ListHabitants.Count >= batiment.nbrMaxHab)
        {
            return;
        }

        List <Habitant> listMetierBat = GameVariables.getListMetier(batiment.typeHabitant);

        if (listMetierBat == null)
        {
            return;
        }

        Habitant villager = GameVariables.listHabitant[0];

        GameVariables.listHabitant.Remove(villager);

        villager.Spawn = batiment;
        GameObject o = villager.GetComponent <Role>().changementRole(batiment.typeHabitant.ToString());

        GameVariables.listHabitantAffecte.Add(villager);
        listMetierBat.Add(villager);
        batiment.ListHabitants.Add(o);
    }
Example #21
0
        public void Start()
        {
            _projectCardManager = GetComponent <ProjectCardManager>();
            _gameVariables      = GameObject.Find("GAME VARIABLES")?.GetComponent <GameVariables>();
            _camera             = Camera.main;
            _cameraAnim         = GameObject.Find("CameraRotator").GetComponent <Animator>();

            TileDictionary = new Dictionary <Vector2, GameObject>();

            string levelGrid; // The actual grid with X and - characters

            if (_gameVariables == null)
            {
                CurrentLevel  = Level.FRANCE;
                _currentLevel = "FRANCE";
                levelGrid     = Levels.GridFull;
            }
            else
            {
                CurrentLevel  = _gameVariables.CurrentLevel;
                _currentLevel = _gameVariables.CurrentLevel.ToString();
                switch (_gameVariables.CurrentLevel)
                {
                case Level.NETHERLANDS:
                    levelGrid = Levels.GridNetherlands;
                    break;

                case Level.GERMANY:
                    levelGrid = Levels.GridGermany;
                    break;

                case Level.FRANCE:
                    levelGrid = Levels.GridFrance;
                    break;

                default:
                    levelGrid = Levels.GridFull;
                    break;
                }
            }
            InitiateGrid(levelGrid);
        }
    void removeFirstFoundHabitantForType(Batiment.role type)
    {
        Batiment batiment = null;

        foreach (Batiment bat in GameVariables.listBatiment)
        {
            if (!bat.isEnDeplacement() && bat.typeHabitant == type && bat.ListHabitants.Count > 0)
            {
                Debug.Log(batiment);
                batiment = bat; break;
            }
        }

        if (batiment == null || batiment.ListHabitants.Count <= 0)
        {
            return;
        }

        GameObject o = batiment.ListHabitants[0];

        if (o.GetComponent <Habitant>() == null)
        {
            return;
        }

        List <Habitant> listMetierBat = GameVariables.getListMetier(batiment.typeHabitant);

        if (listMetierBat == null)
        {
            return;
        }

        Habitant villager = o.GetComponent <Habitant>();

        batiment.ListHabitants.Remove(o);
        listMetierBat.Remove(villager);
        GameVariables.listHabitantAffecte.Remove(villager);

        villager.GetComponent <Role>().changementRole(Batiment.role.Habitant.ToString());
        GameVariables.listHabitant.Add(villager);
    }
Example #23
0
 public void Trigger()
 {
     if (!rotate)
     {
         // Trade
         Direction colorA = GameVariables.GetColor(affectedColors[0]);
         Direction colorB = GameVariables.GetColor(affectedColors[1]);
         GameVariables.SetColor(affectedColors[0], colorB);
         GameVariables.SetColor(affectedColors[1], colorA);
         GameController.Instance.RotateTilesOfColor(affectedColors[0]);
         GameController.Instance.RotateTilesOfColor(affectedColors[1]);
         animator.SetBool("IsSwapping", true);
         return;
     }
     foreach (Colors color in affectedColors)
     {
         GameVariables.SetColor(color, Rotate90(GameVariables.GetColor(color)));
         GameController.Instance.RotateTilesOfColor(color);
     }
     animator.SetBool("IsRotating", true);
 }
    // Update is called once per frame
    void Update()
    {
        gameInfo = GameObject.Find("Click_box");
        info     = gameInfo.GetComponent <GameVariables> ();

        if (info.enemyHealth <= 0)
        {
            info.enemyHealth      += 15 *;
            info.playerExperience += 50;

            if (info.enemiesDefeated < 10)
            {
                info.enemiesDefeated += 1;
            }
            if (info.enemiesDefeated >= 10)
            {
                if (info.currentZone == 0)
                {
                    info.magmaFieldsLv += 1;
                }
                if (info.currentZone == 1)
                {
                    info.frozenTundraLv += 1;
                }
                if (info.currentZone == 2)
                {
                    info.strikingPeaksLv += 1;
                }
                if (info.currentZone == 3)
                {
                    info.swamplandsLv += 1;
                }
                if (info.currentZone == 4)
                {
                    info.infinityTowerLv += 1;
                }
            }
        }
    }
    // Selectiva de cosas
    void Results()
    {
        gameVariables = GameObject.Find("GameVariables").GetComponent <GameVariables>();
        int   recipe = gameVariables.recipe;
        float points = gameVariables.points;

        // 1. 450
        // 2. 550
        // 3. 400
        // 4. 400
        // 5. 400
        switch (recipe)
        {
        case 1:
            CalculateResult(450, points);
            break;

        case 2:
            CalculateResult(550, points);
            break;

        case 3:
            CalculateResult(400, points);
            break;

        case 4:
            CalculateResult(400, points);
            break;

        case 5:
            CalculateResult(400, points);
            break;

        default:
            CalculateResult(100, 0);
            break;
        }
    }
Example #26
0
    // Use this for initialization
    void Start()
    {
        for (int rowNum = -3; rowNum < 6; rowNum++)            //Init with random gems, different from the gem on the left(count-1) and the one below(count-9)
        {
            for (int colNum = -4; colNum < 5; colNum++)
            {
                int  whichGem;
                bool okToAdd = true;
                do
                {
                    okToAdd  = true;
                    whichGem = Random.Range(1, 6);

                    if (fullList.Count > 0)
                    {
                        if (fullList[fullList.Count - 1].gemType == GameVariables.GetTypeFromInt(whichGem) ||
                            GameVariables.GetTypeFromInt(whichGem) == GameVariables.GemType.undefined)
                        {
                            okToAdd = false;
                        }
                    }


                    if (fullList.Count > 8)
                    {
                        if (fullList[fullList.Count - 9].gemType == GameVariables.GetTypeFromInt(whichGem) ||
                            GameVariables.GetTypeFromInt(whichGem) == GameVariables.GemType.undefined)
                        {
                            okToAdd = false;
                        }
                    }
                } while (okToAdd == false);

                CreateCubeAt(colNum, rowNum, GameVariables.GetTypeFromInt(whichGem));
            }
        }
    }
Example #27
0
 public void BUTTON_Close()
 {
     GameVariables.CloseFrontmostMenu();
 }
Example #28
0
    void Update()
    {
        float joyStickX = xboxInput.getXaxis();

        //Color choice
        //prevent from infinite change
        if (currentState == 0)
        {
            if (joyStickX < 0.5f && joyStickX > -0.5f)
            {
                changedRecently = false;
            }

            //change color for player
            if (joyStickX == 1 && !changedRecently)
            {
                SoundManager.instance.RandomizeSfx(choice);
                currentColor = GameVariables.getNextColorRight(currentColor, usedColors);
                colorImages();
                changedRecently = true;
            }
            else if (joyStickX == -1 && !changedRecently)
            {
                SoundManager.instance.RandomizeSfx(choice);
                currentColor = GameVariables.getNextColorLeft(currentColor, usedColors);
                colorImages();
                changedRecently = true;
            }

            if (usedColors.ContainsValue(currentColor))
            {
                currentColor = GameVariables.getNextColorRight(currentColor, usedColors);
                colorImages();
            }
        }

        //Bonus Choice
        if (currentState == 1)
        {
            transform.FindChild("Player").gameObject.SetActive(false);
            bonusGO.SetActive(true);
            if (joyStickX < 0.5f && joyStickX > -0.5f)
            {
                changedRecently = false;
            }

            //change color for player
            if (joyStickX == 1 && !changedRecently)
            {
                SoundManager.instance.RandomizeSfx(choice);
                currentBonus = GameVariables.getNextBonusRight(currentBonus);
                bonusImages();
                changedRecently = true;
            }
            else if (joyStickX == -1 && !changedRecently)
            {
                SoundManager.instance.RandomizeSfx(choice);
                currentBonus = GameVariables.getNextBonusLeft(currentBonus);
                bonusImages();
                changedRecently = true;
            }
        }
        else
        {
            bonusGO.SetActive(false);
        }
        if (currentState == 2 && !changedRecently)
        {
            transform.FindChild("Both/Bonus").transform.GetComponent <Image>().sprite = currentBonus.GetComponent <Image> ().sprite;
            transform.FindChild("Both").gameObject.SetActive(true);
        }
        if (currentState == (maxState - 1) && !changedRecently)
        {
            transform.FindChild("InstructionsPanel/Validate").gameObject.SetActive(false);
        }
        if (Input.GetKeyDown(xboxInput.A) || Input.GetKeyDown(xboxInput.BStart))
        {
            SoundManager.instance.RandomizeSfx(validate);
            int currentReady = nbReady;
            //go to next state and update Debug.Loging
            if (currentState < maxState)
            {
                currentState++;

                if (!usedColors.ContainsValue(currentColor))
                {
                    usedColors.Add(playerControllerId, currentColor);
                }

                if (currentState == maxState - 1)
                {
                    nbReady++;
                }
                if (currentState < maxState)
                {
                    text.text = textState [currentState];
                }
            }
            //if there are enough player, show "Play" text
            if (nbReady >= GameVariables.minPlayers && nbReady >= GameObject.Find("CheckNewControllers").transform.GetComponent <CheckNewControllers> ().GetNbPlayers())
            {
                playText.enabled = true;
            }
            if (currentState == maxState && currentReady >= GameVariables.minPlayers && currentReady >= GameObject.Find("CheckNewControllers").transform.GetComponent <CheckNewControllers> ().GetNbPlayers())
            {
                SceneManager.LoadScene("ModeSelectionMenu");
            }
        }
        else if (Input.GetKeyDown(xboxInput.B))
        {
            //Player wants to go back to previous menu
            if (currentState == 0)
            {
                SoundManager.instance.RandomizeSfx(close);
                SceneManager.LoadScene(1);
            }
            //go to previous state and update Debug.Loging
            if (currentState > 0)
            {
                if (currentState == maxState - 1)
                {
                    nbReady--;
                }

                currentState--;
                switch (currentState)
                {
                case 0:
                    transform.FindChild("Player").gameObject.SetActive(true);
                    transform.FindChild("InstructionsPanel/Validate").gameObject.SetActive(true);
                    usedColors.Remove(playerControllerId);
                    break;

                case 1:
                    transform.FindChild("InstructionsPanel/Validate").gameObject.SetActive(true);
                    transform.FindChild("Both").gameObject.SetActive(false);
                    break;

                case 2:
                    transform.FindChild("InstructionsPanel/Validate").gameObject.SetActive(true);
                    transform.FindChild("Both").gameObject.SetActive(true);
                    break;

                default:
                    break;
                }
                text.text = textState [currentState];
            }
            //if there are not enough player, hide "Play" text
            if (nbReady < GameObject.Find("CheckNewControllers").transform.GetComponent <CheckNewControllers> ().GetNbPlayers())
            {
                playText.enabled = false;
            }
        }
    }
Example #29
0
    //GameObject gold;

    void Start()
    {
        gv = GameObject.Find("GameVariables").GetComponent <GameVariables>();
    }
Example #30
0
 void OnDestroy()
 {
     Debug.Log("GAME VARIABLES DELETED\nSaving Variables to PlayerPrefs.");
     GameVariables.SaveProgress();
     GameVariables.SaveOptions();
 }
        public void Load(GameVariables orig)
        {
            CustomBarnKit.log("Loading new career/science config");

#if DEBUG
            debug = true;
#endif

            original = orig;

            // Init our values with the one from the default config
            reputationAddition    = orig.reputationAddition;
            reputationSubtraction = orig.reputationSubtraction;

            ConfigNode[] configs = GameDatabase.Instance.GetConfigNodes("CUSTOMBARNKIT");

            if (configs == null || configs.Length == 0)
            {
                CustomBarnKit.log("No config to load");
                return;
            }

            if (configs.Length > 1)
            {
                CustomBarnKit.log("More than 1 CustomBarnKit node found. Loading the first one");
            }

            ConfigNode config = configs[0];

            ConfigNode node = new ConfigNode();
            if (config.TryGetNode("VAB", ref node))
            {
                LoadValue(node, "levels", ref levelsVAB);

                LoadValue(node, "upgrades", ref upgradesVAB);
                LoadValue(node, "upgradesVisual", ref upgradesVisualVAB);
                LoadValue(node, "actionGroupsCustomUnlock", ref actionGroupsCustomUnlockVAB);
                LoadValue(node, "actionGroupsStockUnlock", ref actionGroupsStockUnlockVAB);
                LoadValue(node, "partCountLimit", ref partCountLimitVAB);
            }

            if (config.TryGetNode("SPH", ref node))
            {
                LoadValue(node, "levels", ref levelsSPH);

                LoadValue(node, "upgrades", ref upgradesSPH);
                LoadValue(node, "upgradesVisual", ref upgradesVisualSPH);
                LoadValue(node, "actionGroupsCustomUnlock", ref actionGroupsCustomUnlockSPH);
                LoadValue(node, "actionGroupsStockUnlock", ref actionGroupsStockUnlockSPH);
                LoadValue(node, "partCountLimit", ref partCountLimitSPH);
            }

            if (config.TryGetNode("LAUNCHPAD", ref node))
            {
                LoadValue(node, "levels", ref levelsLaunchPad);

                LoadValue(node, "upgrades", ref upgradesLaunchPad);
                LoadValue(node, "upgradesVisual", ref upgradesVisualLaunchPad);
                LoadValue(node, "craftMassLimit", ref craftMassLimitLaunchPad);
                LoadValue(node, "craftSizeLimit", ref craftSizeLimitLaunchPad);
                LoadValue(node, "useBuilding", ref useBuildingLaunchPad);
            }

            if (config.TryGetNode("RUNWAY", ref node))
            {
                LoadValue(node, "levels", ref levelsRunway);

                LoadValue(node, "upgrades", ref upgradesRunway);
                LoadValue(node, "upgradesVisual", ref upgradesVisualRunway);
                LoadValue(node, "craftMassLimit", ref craftMassLimitRunway);
                LoadValue(node, "craftSizeLimit", ref craftSizeLimitRunway);
                LoadValue(node, "useBuilding", ref useBuildingRunway);
            }

            if (config.TryGetNode("ASTRONAUTS", ref node))
            {
                LoadValue(node, "levels", ref levelsAstronauts);

                LoadValue(node, "upgrades", ref upgradesAstronauts);
                LoadValue(node, "upgradesVisual", ref upgradesVisualAstronauts);
                LoadValue(node, "recruitHireBaseCost", ref recruitHireBaseCost);
                LoadValue(node, "recruitHireFlatRate", ref recruitHireFlatRate);
                LoadValue(node, "recruitHireRateModifier", ref recruitHireRateModifier);
                LoadValue(node, "recruitHireFixedRate", ref recruitHireFixedRate);
                LoadValue(node, "unlockedEVA", ref unlockedEVA);
                LoadValue(node, "unlockedEVAClamber", ref unlockedEVAClamber);
                LoadValue(node, "unlockedEVAFlags", ref unlockedEVAFlags);
                LoadValue(node, "homebodyAtmoEVA", ref homebodyAtmoEVA);
                LoadValue(node, "homebodyEVA", ref homebodyEVA);
                LoadValue(node, "activeCrewLimit", ref activeCrewLimit);
                LoadValue(node, "crewLevelLimit", ref crewLevelLimit);
            }

            if (config.TryGetNode("MISSION", ref node))
            {
                LoadValue(node, "levels", ref levelsMission);

                LoadValue(node, "upgrades", ref upgradesMission);
                LoadValue(node, "upgradesVisual", ref upgradesVisualMission);
                LoadValue(node, "unlockedFlightPlanning", ref unlockedFlightPlanning);
                LoadValue(node, "activeContractsLimit", ref activeContractsLimit);
                LoadValue(node, "scoreSituationHome", ref scoreSituationHome);
                LoadValue(node, "scoreSituationOther", ref scoreSituationOther);

                LoadValue(node, "partRecoveryValueFactor", ref partRecoveryValueFactor);
                LoadValue(node, "resourceRecoveryValueFactor", ref resourceRecoveryValueFactor);
                LoadValue(node, "reputationKerbalDeath", ref reputationKerbalDeath);
                LoadValue(node, "reputationKerbalRecovery", ref reputationKerbalRecovery);

                LoadValue(node, "contractPrestigeTrivial", ref contractPrestigeTrivial);
                LoadValue(node, "contractPrestigeSignificant", ref contractPrestigeSignificant);
                LoadValue(node, "contractPrestigeExceptional", ref contractPrestigeExceptional);

                LoadValue(node, "contractDestinationWeight", ref contractDestinationWeight);
                LoadValue(node, "contractFundsAdvanceFactor", ref contractFundsAdvanceFactor);
                LoadValue(node, "contractFundsCompletionFactor", ref contractFundsCompletionFactor);
                LoadValue(node, "contractFundsFailureFactor", ref contractFundsFailureFactor);
                LoadValue(node, "contractReputationCompletionFactor", ref contractReputationCompletionFactor);
                LoadValue(node, "contractReputationFailureFactor", ref contractReputationFailureFactor);
                LoadValue(node, "contractScienceCompletionFactor", ref contractScienceCompletionFactor);
            }

            if (config.TryGetNode("TRACKING", ref node))
            {
                LoadValue(node, "levels", ref levelsTracking);

                LoadValue(node, "upgrades", ref upgradesTracking);
                LoadValue(node, "upgradesVisual", ref upgradesVisualTracking);
                LoadValue(node, "unlockedSpaceObjectDiscovery", ref unlockedSpaceObjectDiscovery);
                LoadValue(node, "orbitDisplayMode", ref orbitDisplayMode);
                LoadValue(node, "patchesAheadLimit", ref patchesAheadLimit);
                LoadValue(node, "trackedObjectLimit", ref trackedObjectLimit);
                LoadValue(node, "DSNRange", ref DSNRange);
                LoadValue(node, "DSNRangeCurve", ref DSNRangeCurve);
                LoadValue(node, "DSNPowerCurve", ref DSNPowerCurve);
                LoadValue(node, "DSNScienceCurve", ref DSNScienceCurve);
            }

            if (config.TryGetNode("ADMINISTRATION", ref node))
            {
                LoadValue(node, "levels", ref levelsAdministration);

                LoadValue(node, "upgrades", ref upgradesAdministration);
                LoadValue(node, "upgradesVisual", ref upgradesVisualAdministration);
                LoadValue(node, "activeStrategyLimit", ref activeStrategyLimit);
                LoadValue(node, "strategyCommitRange", ref strategyCommitRange);
            }

            if (config.TryGetNode("RESEARCH", ref node))
            {
                LoadValue(node, "levels", ref levelsRnD);

                LoadValue(node, "upgrades", ref upgradesRnD);
                LoadValue(node, "upgradesVisual", ref upgradesVisualRnD);
                LoadValue(node, "dataToScienceRatio", ref dataToScienceRatio);
                LoadValue(node, "scienceCostLimit", ref scienceCostLimit);
                LoadValue(node, "unlockedFuelTransfer", ref unlockedFuelTransfer);
            }
        }
Example #32
0
    //Private Functions
    private void initUI()
    {
        //Set Title Text
        titleText.text = GameVariables.batimentSelectionne.nomBatiment;
        //Set Desc Text
        descText.text = GameVariables.batimentSelectionne.description;

        //Check Effectifs UI Needed + Set Pop Manager Actions
        if (GameVariables.batimentSelectionne.nbrMaxHab != 0)
        {
            buildingPopulationManager.gameObject.SetActive(true);
            buildingPopulationManager.gameObject.GetComponent <RectTransform>().localScale = new Vector3(1, 1, 1);
            secondSeparator.gameObject.SetActive(true);
            secondSeparator.gameObject.GetComponent <RectTransform>().localScale = new Vector3(1, 1, 1);

            buildingPopulationManager.setUpAction(() => {
                if (GameVariables.listHabitant.Count == 0)
                {
                    return;
                }

                Batiment batiment = GameVariables.batimentSelectionne;
                if (batiment == null || batiment.isEnDeplacement() || batiment.ListHabitants.Count >= batiment.nbrMaxHab)
                {
                    return;
                }

                List <Habitant> listMetierBat = GameVariables.getListMetier(batiment.typeHabitant);
                if (listMetierBat == null)
                {
                    return;
                }

                Habitant villager = GameVariables.listHabitant[0];
                GameVariables.listHabitant.Remove(villager);

                villager.Spawn = batiment;
                GameObject o   = villager.GetComponent <Role>().changementRole(batiment.typeHabitant.ToString());
                GameVariables.listHabitantAffecte.Add(villager);
                listMetierBat.Add(villager);
                batiment.ListHabitants.Add(o);
            });

            buildingPopulationManager.setDownAction(() => {
                Batiment batiment = GameVariables.batimentSelectionne;
                if (batiment == null || batiment.isEnDeplacement())
                {
                    return;
                }
                if (batiment.ListHabitants.Count == 0)
                {
                    return;
                }

                GameObject o = batiment.ListHabitants[0];

                if (o.GetComponent <Habitant>() == null)
                {
                    return;
                }

                List <Habitant> listMetierBat = GameVariables.getListMetier(batiment.typeHabitant);
                if (listMetierBat == null)
                {
                    return;
                }

                Habitant villager = o.GetComponent <Habitant>();
                batiment.ListHabitants.Remove(o);
                listMetierBat.Remove(villager);
                GameVariables.listHabitantAffecte.Remove(villager);

                villager.GetComponent <Role>().changementRole(Batiment.role.Habitant.ToString());
                GameVariables.listHabitant.Add(villager);
            });
        }
        else
        {
            buildingPopulationManager.gameObject.SetActive(false);
            buildingPopulationManager.gameObject.GetComponent <RectTransform>().localScale = new Vector3(0, 0, 0);
            secondSeparator.gameObject.SetActive(false);
            secondSeparator.gameObject.GetComponent <RectTransform>().localScale = new Vector3(0, 0, 0);
        }

        //Check Prod UI Needed
        if (GameVariables.batimentSelectionne is BatimentRessource)
        {
            buildingProdUI.gameObject.SetActive(true);
            buildingProdUI.gameObject.GetComponent <RectTransform>().localScale = new Vector3(1, 1, 1);
            thirdSeparator.gameObject.SetActive(true);
            thirdSeparator.gameObject.GetComponent <RectTransform>().localScale = new Vector3(1, 1, 1);
        }
        else
        {
            buildingProdUI.gameObject.SetActive(false);
            buildingProdUI.gameObject.GetComponent <RectTransform>().localScale = new Vector3(0, 0, 0);
            thirdSeparator.gameObject.SetActive(false);
            thirdSeparator.gameObject.GetComponent <RectTransform>().localScale = new Vector3(0, 0, 0);
        }

        //Check Upgrade UI Needed + Set Upgrade Action
        if (GameVariables.batimentSelectionne.batUpgrade != null)
        {
            buildingUpgradeUI.gameObject.SetActive(true);
            buildingUpgradeUI.gameObject.GetComponent <RectTransform>().localScale = new Vector3(1, 1, 1);

            buildingUpgradeUI.setUpgradeAction(() => {
                GameVariables.batimentSelectionne.upgradeStructure();
            });
        }
        else
        {
            buildingUpgradeUI.gameObject.SetActive(false);
            buildingUpgradeUI.gameObject.GetComponent <RectTransform>().localScale = new Vector3(0, 0, 0);
        }
    }
Example #33
0
 private void Start()
 {
     variablesScript = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameVariables>();
     exitButton.onClick.AddListener(ExitGame);
 }
Example #34
0
 //GameObject gold;
 void Start()
 {
     gv = GameObject.Find("GameVariables").GetComponent<GameVariables>();
 }
Example #35
0
 void Start()
 {
     gv = GameObject.Find("GameVariables").GetComponent<GameVariables>();
     StartCoroutine(SpawnTheKnights());
 }
Example #36
0
    // Update is called once per frame
    void Update()
    {
        if (playerHitted)
        {
            if (hittedCounter < hittedTime)
            {
                hittedCounter += Time.deltaTime;
            }
            else
            {
                hittedCounter = 0.0f;
                playerHitted  = false;
            }
        }

        if (isDead)
        {
            if (deadAnimationCounter < deadAnimationTime)
            {
                deadAnimationCounter += Time.deltaTime;
            }
            else
            {
                deadAnimationCounter = 0.0f;
                isDead = false;
            }
        }

        bool isTooLittleMana = false;

        if (slowZone.manualUpdate(manaBar.Value, ref isTooLittleMana))
        {
            useMana((int)GameVariables.Abilities.Time);
        }
        if (GameVariables.GameMode == GameVariables.GameModes.God && GameVariables.Ability == GameVariables.Abilities.Thunder &&
            Input.GetButtonDown("Fire1"))
        {
            if (manaBar.Value >= (int)GameVariables.Abilities.Thunder)
            {
                useMana((int)GameVariables.Abilities.Thunder);
                lightningBolt.setPositions(GameVariables.getPos());
                lightningBolt.Trigger();
                GameObject objectHit = GameVariables.getObjectHit();
                if (objectHit != null)
                {
                    LightningHitable hitableObject = objectHit.GetComponent <LightningHitable>();
                    if (hitableObject != null)
                    {
                        hitableObject.afterHit();
                    }
                }
            }
            else
            {
                //not enough mana!!!oneoneone
                Debug.Log("Too little mana for thunder");
                isTooLittleMana = true;
            }
        }
        if (isTooLittleMana)
        {
            manaBar.blink();
        }

        if (Input.GetKey(KeyCode.H))
        {
            manaToHealth();
        }
        if (Input.GetKey(KeyCode.M))
        {
            healthToMana();
        }


        //***********************************
        //for debug only!

        /*if (Input.GetKeyDown(KeyCode.I))
         * {
         *      takeDamage(-10);
         * }
         * if (Input.GetKeyDown(KeyCode.O))
         * {
         *      takeDamage(10);
         * }*/
        //***********************************
    }