Inheritance: MonoBehaviour
Example #1
0
        private static void SetBar(ResourceBar resourceBar, RectTransform barTransform, float barWidth)
        {
            var barSize = barTransform.sizeDelta;

            barSize.x = resourceBar.Ratio * barWidth;
            barTransform.sizeDelta = barSize;
        }
Example #2
0
    private void OnSpawned(CharacterBase charBase)
    {
        CharacterBases.Add(charBase);

        healthEnergyUI       = Instantiate(HealthEnergyUIPrefab);
        healthEnergyUI.owner = charBase;
    }
Example #3
0
 private void SetStats(int level)
 {
     Level   = level;
     Health  = new ResourceBar(StatsGenerator.GetHeroHealth(level));
     Stamina = new ResourceBar(StatsGenerator.GetHeroStamina(level));
     Weapon  = new Weapon(level);
 }
    // Use this for initialization
    void Start()
    {
        if (instance == null)
            instance = this;

        abilityBehaviours = GameObject.Find ("Player").GetComponent<AbilityBehaviours> ();
        powerBar = barManager.GetComponent<ResourceBar> ();
        //input = GameObject.Find ("Player").GetComponent<InputHandler> ();
        //	uiIndicator.color = ImagiC;
    }
Example #5
0
        public override void _Ready()
        {
            base._Ready();

            healthController = GetNode <HealthController>("Controllers/HealthController");
            healthBar        = GetNode <ResourceBar>("HealthBarPositioner/HealthBar");

            healthBar.Init(healthController);
            healthController.OnDie += Died;

            GameRoundManager.S.RegisterTurnTaker(this);
        }
Example #6
0
	public void Start()
	{
		BuildBar ();

		activeBarIndex = 0;
		activeBar = transform.GetChild (activeBarIndex).GetComponent<ResourceBar> ();
		activeBar.Width = activeBarWidth;

		target.died += PhaseCompleted;

		transitioning = false;
	}
Example #7
0
	private void BuildBar()
	{
		if (resourceBarPrefab != null)
		{
			for (int i = 0; i < numberOfPhases; i++)
			{
				GameObject barObj = Instantiate (resourceBarPrefab, gameObject.transform, false);
				ResourceBar bar = barObj.GetComponent<ResourceBar> ();
				bar.Front.color = barColor;
				bar.Back.color = barBackColor;
				bar.Front.fillAmount = 1f;
				bar.Width = inactiveBarWidth;
			}
		}
	}
Example #8
0
        protected override void DrawSelf(SpriteBatch spriteBatch)
        {
            Vector2 mousePosition = new Vector2(Main.mouseX, Main.mouseY);

            if (ResourceBar.ContainsPoint(mousePosition))
            {
                Main.LocalPlayer.mouseInterface = true;
            }

            if (_dragging)
            {
                ResourceBar.Left.Set(mousePosition.X - _mouseOffset.X, 0f);
                ResourceBar.Top.Set(mousePosition.Y - _mouseOffset.Y, 0f);

                Recalculate();
            }
        }
Example #9
0
    // Update is called once per frame
    void Update()
    {
        //Switch recharge target
        if (checkSwitchRechargeTarget())
        {
            rechargeTargetIndex++;
            rechargeTargetIndex = rechargeTargetIndex % resourceBars.Count;
            rechargeTarget      = resourceBars[rechargeTargetIndex];
        }
        //Recharge
        rechargeTarget.recharge(rechargeRate * Time.deltaTime);

        //Process Inputs
        checkMovement();
        if (ability1)
        {
            if (checkAbility(ability1, "Ability1"))
            {
                ability1.activate();
            }
        }
        if (ability2)
        {
            if (checkAbility(ability2, "Ability2"))
            {
                ability2.activate();
            }
        }
        if (ability3)
        {
            if (checkAbility(ability3, "Ability3"))
            {
                ability3.activate();
            }
        }

        //Close program
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Application.Quit();
        }
    }
Example #10
0
	private IEnumerator TransitionPhases()
	{
		transitioning = true;

		ResourceBar prevBar = activeBar;
		activeBarIndex++;
		activeBar = transform.GetChild (activeBarIndex).GetComponent<ResourceBar> ();
		prevBar.Front.fillAmount = 0f;

        BossController.NextPhase();

		for (float dur = phaseTransitionDuration, initDur = dur; dur > 0f; dur -= Time.deltaTime)
		{
			prevBar.Width = Mathf.Lerp (inactiveBarWidth, activeBarWidth, dur / initDur);
			activeBar.Width = Mathf.Lerp (activeBarWidth, inactiveBarWidth, dur / initDur);
			yield return null;
		}

		prevBar.Width = inactiveBarWidth;
		activeBar.Width = activeBarWidth;

		transitioning = false;
	}
Example #11
0
	// Use this for initialization
	void Start () {
        populationBar = transform.Find("PopulationBar").GetComponent<ResourceBar>();
        populationBar.Initialize();
        populationBar.Hide(0);

        energyBar = transform.Find("EnergyBar").GetComponent<ResourceBar>();
        energyBar.Initialize();
        if (SceneManager.GetActiveScene().buildIndex != GameManager.SystemLevel) {
            energyBar.Hide(0);
        }
        else {
            energyBar.Show(0);
        }

        spacebuxBar = transform.Find("SpacebuxBar").GetComponent<ResourceBar>();
        spacebuxBar.Initialize();
        spacebuxBar.Show(0);

        // TO DO literally just copy and paste this for population and power
        spacebuxBar.Value = PlayerData.instance.Spacebux;
        if (virtualPosition != null)
            virtualPosition.text = "Position: <" + Mathf.FloorToInt(GameManager.instance.virtualPosition.x) + " , " + Mathf.FloorToInt(GameManager.instance.virtualPosition.y) + ">";
    }
Example #12
0
 // Use this for initialization
 protected virtual void Start()
 {
     rb2d           = GetComponent <Rigidbody2D>();
     rechargeTarget = resourceBars[rechargeTargetIndex];
     GetComponent <HealthPool>().onDeath += onDeath;
 }
Example #13
0
    public void executeResult(ResourceBar inResourceBar)
    {
        //ChallengeManager cm = GameObject.Find ("Challenge Manager").GetComponent <ChallengeManager>();
        if (num == 1)
        {
            resultText = "The other elves angrily leave, but the troll is safe and is thankful for your help and joins you.";
            inResourceBar.addResource("sprites/spr_troll");
            ChallengeManager.setNext(2);
        }
        if (num == 2)
        {
            resultText = "The troll is captured under a net and the other elves thank you for taking their side.";
            ChallengeManager.setNext(2);
        }
        if (num == 3)
        {
            if (inResourceBar.checkResource("sprites/spr_troll"))
            {
                resultText = "You make it through the gate and the troll is reunited with his family.";
                GameManager.AddSurvivedCharacter(new EndItemInfo("Rojin - Troll", Resources.Load <Sprite>("sprites/spr_troll")));
                inResourceBar.useResource("sprites/spr_troll");
            }
            else
            {
                resultText = "Hmmm doesn't look like you have a troll here to help you. Maybe you should see if you can find one...";
            }
        }
        if (num == 4)
        {
            int rand = Random.Range(1, 2);
            if (rand == 1)
            {
                resultText = "You unintentionally offend them and they whack you with their club. You lose 5 health points.";
                inResourceBar.incrementHealth(-5);
            }
            else if (rand == 2)
            {
                resultText = "You got lucky! The trolls let you through the gate.";
            }
        }
        if (num == 5)
        {
            resultText = "The pixie is grateful and asks if he can hang out with you for a bit. You let him tag along, why not?";
            inResourceBar.addResource("sprites/spr_pixie");
            ChallengeManager.setNext(4);
        }
        if (num == 6)
        {
            resultText = "You leave the pixie laying on the ground with it’s torn wing and continue on your journey.";
            ChallengeManager.setNext(4);
        }
        if (num == 7)
        {
            resultText = "You lost some time going around.";
            GameManager.changeTime(20);
        }
        if (num == 8)
        {
            if (inResourceBar.checkResource("sprites/spr_pixie"))
            {
                resultText = "You make it through the door.";
                GameManager.AddSurvivedCharacter(new EndItemInfo("Solara - Pixie", Resources.Load <Sprite>("sprites/spr_pixie")));
                inResourceBar.useResource("sprites/spr_pixie");
            }
            else
            {
                resultText = "Hmmm doesn't look like you have a pixie here to help you. Maybe you should see if you can find one...";
            }
        }
        if (num == 9)
        {
            resultText = "The unicorn refuses to join based on your team’s negative response towards it. Some of your team is furious and insult you for it, which makes you feel bad.";
            inResourceBar.incrementHealth(-10);
        }
        if (num == 10)
        {
            resultText = "Your team is happy, but the unicorn blocks your path.";
            GameManager.changeTime(20);
        }

        if (num == 11)
        {
            resultText = "A unicorn set this pot of gold as a test. By not stealing it, you gained its trust and he offers to split the pot with you in exchange for some food.";
            GameManager.AddSurvivedCharacter(new EndItemInfo("Nightwind - Unicorn", Resources.Load <Sprite>("sprites/unicorn")));
            inResourceBar.addResource("sprites/PotofGold");
        }
        if (num == 12)
        {
            float rand = Random.value;
            if (rand < 0.5f)
            {
                resultText = "You now have loads of coins.";
                inResourceBar.addResource("sprites/PotofGold");
            }
            if (rand >= 0.5f)
            {
                resultText = "A unicorn placed the pot as a trick and you fell for it. He takes the gold back and pokes you with his horn.";
                inResourceBar.incrementHealth(-5);
            }
        }
        if (num == 13)
        {
            resultText = "You lost a lot of time making fun of this creature.";
            GameManager.changeTime(10);
        }
        if (num == 14)
        {
            resultText = "You continue on your journey.";
        }
        if (num == 15)
        {
            int rand = Random.Range(1, 2);
            if (rand == 1)
            {
                resultText = "The elves get mad and continue teasing the pixie anyway. They also insult you! You decide to move on and continue on your journey.";
            }
            if (rand == 2)
            {
                resultText = "You save the pixie! As a token of appreciation it gives you 5 health points and joins your team!";
                inResourceBar.incrementHealth(5);
            }
        }
        if (num == 16)         //come back to this one
        {
            inResourceBar.checkResource("sprites/potion");
            resultText = "You are now a wolf! The other wolves let you pass. But now you are stuck as a wolf for an unknown amount of time.";
            inResourceBar.useResource("sprites/potion");
        }
        if (num == 17)
        {
            int rand = Random.Range(1, 2);
            if (rand == 1)
            {
                resultText = "The werewolves refuse to listen to you and you must go a different route.";
                GameManager.changeTime(30);
            }
            if (rand == 2)
            {
                resultText = "The werewolves determine that you are cool and let you through.";
            }
        }

        if (num == 19)
        {
            int rand = Random.Range(1, 2);
            if (rand == 1)
            {
                resultText = "You learn that you can’t solve it by yourself and can’t get around wizard.";
                GameManager.changeTime(30);
            }
            if (rand == 2)
            {
                resultText = "You get through but have to abandon some of your team.";
            }
        }
        if (num == 20)
        {
            resultText = "You solve all three puzzles, but lose more time.";
            GameManager.changeTime(30);
        }
        if (num == 21)
        {
            resultText = "You run into a different group of ogres, and the one you helped helps you pass their clan.";
        }
        if (num == 22)
        {
            resultText = "You have to take a longer route because you cannot pass through the clan.";
            GameManager.changeTime(30);
        }
        if (num == 23)
        {
            resultText = "She sneaks away with some of your food, which causes you to go hungry.";
            inResourceBar.incrementHealth(-10);
        }
        if (num == 24)
        {
            resultText = "Turns out she was a wanted fairy who often conned travelers - you get coin reward.";
            inResourceBar.addResource("sprites/PotofGold");
            ChallengeManager.setNext(27);
        }
        if (num == 25)
        {
            resultText = "This takes time, but the pixie is so grateful that it rewards you with 5 health points.";
            inResourceBar.incrementHealth(5);
        }
        if (num == 26)
        {
            resultText = "You continue on your way.";
        }
        if (num == 27)
        {
            resultText = "The pixie looks angry, but you got some sweet snacks that make you feel better and continue on your way.";
            inResourceBar.incrementHealth(5);
        }
        if (num == 28)
        {
            resultText = "The dwarf is helpful and points you in the right direction, which saves you some time";
            GameManager.changeTime(-20);
        }
        if (num == 29)
        {
            resultText = "You’re in an enchanted maze, why would you think you know where you are going? You get lost and it takes you a while to get back on the path.";
            GameManager.changeTime(20);
        }
        if (num == 30)
        {
            resultText = "That was nice of you. You don't even lose any time, becuase talking through the directions with the giant helped you decide faster which way you wanted to go.";
        }
        if (num == 31)
        {
            resultText = "The giant looks disappointed, but you nervously scamper down the path.";
        }
        if (num == 32)
        {
            resultText = "The elves are thrilled to have more company! The song is interesting- you note a line that curiously says that the secret is 'Hans Christian Anderson'. Hmm.";
            GameManager.changeTime(20);
            ChallengeManager.setNext(16);
            ChallengeManager.setCorrect(true);
        }
        if (num == 33)
        {
            resultText = "You continue on your way.";
            ChallengeManager.setNext(16);
            ChallengeManager.setCorrect(false);
        }
        if (num == 34)
        {
            if (ChallengeManager.getCorrect())
            {
                resultText = "You enter the correct password Hans Christian Anderson and make it through!";
            }
            else
            {
                resultText = "Maybe you should have listened to those elves, they probably had some useful information in their song. Because you don't have the password, you run into the gate until it breaks. Ouch.";
                inResourceBar.incrementHealth(-5);
            }
        }
        if (num == 35)
        {
            resultText = "You run into the gate until it breaks. Ouch.";
            inResourceBar.incrementHealth(-5);
        }
        if (num == 37)
        {
            resultText = "You continue down the path.";
        }
        if (num == 38)
        {
            int rand = Random.Range(1, 2);
            if (rand == 1)
            {
                resultText = "The witch is so grateful that she gives you a potion as a thank you. Sweet!";
                inResourceBar.addResource("sprites/potion");
            }
            if (rand == 2)
            {
                resultText = "The witch pulls you down with her in an attempt to steal all of your stuff. Thankfully you escape with only a small loss to your health.";
                inResourceBar.incrementHealth(-5);
            }
        }
        if (num == 39 || num == 40)
        {
            resultText = "Hopefully no one saw that!";
            inResourceBar.incrementHealth(-5);
        }
        if (num == 41)
        {
            resultText = "He complies, but is grumpy about it and mutters about your ignorance. You take a new path to avoid contact with him.";
            GameManager.changeTime(10);
        }
        if (num == 42)
        {
            resultText = "He complies, but is grumpy about it and mutters about your ignorance. You take a new path to avoid contact with him.";
            GameManager.changeTime(10);
        }
        if (num == 43)
        {
            resultText = "Although the argument was uncomfortable, the character appreciates your patience and explains what the pendant means to him. Turns out, it represents something completely different to him than to you. Interesting.";
        }
        if (num == 44)
        {
            resultText = "Ahhh.. so relaxing. That was refreshing.";
            GameManager.changeTime(10);
            inResourceBar.incrementHealth(5);
        }
        if (num == 45 || num == 48)
        {
            resultText = "Continue down the path.";
        }
        if (num == 46)
        {
            resultText = "Continue down the path.";
            ChallengeManager.setNext(26);
        }
        if (num == 47)
        {
            resultText = "The wizard scarfs down the loaf of bread and jumps up, feeling much better. He hands you a potion bottle as a thank you.";
            inResourceBar.addResource("sprites/potion");
            GameManager.AddSurvivedCharacter(new EndItemInfo("Benjamin - Wizard", Resources.Load <Sprite>("sprites/spr_wizard")));
            ChallengeManager.setNext(26);
        }
        if (num == 49)
        {
            resultText = "You give the pixie your bottle of potion, which magically heals her. She is grateful for you help and flutters away.";
            GameManager.AddSurvivedCharacter(new EndItemInfo("Flix - Pixie", Resources.Load <Sprite>("sprites/spr_pixie")));
            if (inResourceBar.checkResource("sprites/potion"))
            {
                inResourceBar.useResource("sprites/potion");
            }
            else
            {
                inResourceBar.incrementHealth(-3);
            }
        }
        if (num == 50)
        {
            resultText = "Continue down the path";
        }
        if (num == 51)
        {
            resultText = "You give the family the medicine and are relieved to see their baby starting to feel better";
            GameManager.AddSurvivedCharacter(new EndItemInfo("Jada - Fairy", Resources.Load <Sprite>("sprites/fairy")));
            inResourceBar.useResource("sprites/potofgold");
        }

        // TO DO store a ref so Find isn't called every time we need to call GUIManager
        GameObject.Find("Canvas").GetComponent <GUIManager>().showResult(resultText);
    }