Ejemplo n.º 1
0
        public override string ToString()
        {
            var hearts = Hearts == 0.0 ? "none" : Hearts.ToString();

            return($"Recipe {{ Type = '{Type}', Name = '{Name}', Hearts = {hearts}, " +
                   $"Effects = {Helpers.ArrayToString(Effects)}, Ingredients = {Helpers.ArrayToString(Ingredients)} }}");
        }
Ejemplo n.º 2
0
    public void DoDamage(Hearts amount, Vector3 pos, Vector3 dir)
    {
        if (IsInvulnerable || !enabled || IsKilled)
        {
            return;
        }
        if (mainHealth)
        {
            mainHealth.DoDamage(amount, pos, dir);
            return;
        }

        ActualHp -= amount;
        if (ActualHp.TotalPoints <= 0)
        {
            Destruct();
            return;
        }

        if (damagedEffect && createDamageEffect)
        {
            Quaternion effectRotation = Quaternion.LookRotation(dir);
            Destroy(Instantiate(damagedEffect, pos, effectRotation), damageEffectLifetime);
        }

        if (ActualInvulnerableTime > 0)
        {
            _invulnerableTimer = ActualInvulnerableTime;
        }

        onDamaged?.Invoke(ActualHp.TotalPoints);
        onDamagedEvent.Invoke();
    }
Ejemplo n.º 3
0
 // Use this for initialization
 void Start()
 {
     hp         = maxHp;
     lifes      = 3;
     lifeCanvas = GameObject.FindObjectOfType <Hearts>();
     lifeCanvas.ChangeLife(lifes);
 }
Ejemplo n.º 4
0
    public void DoDamage(int amount)
    {
        Hearts newDamage = new Hearts();

        newDamage.hearts = amount;
        DoDamage(newDamage, transform.position + Vector3.back * .25f, Vector3.forward);
    }
Ejemplo n.º 5
0
    public static Hearts operator+(Hearts left, int right)
    {
        Hearts newHP = new Hearts();

        newHP.Recalculate(left.TotalPoints + right);
        return(newHP);
    }
Ejemplo n.º 6
0
 public void SetHp(Hearts newHp)
 {
     if (!enabled)
     {
         return;
     }
     currentHp.Value = newHp;
 }
Ejemplo n.º 7
0
    public void willGetACardWithJacks()
    {
        var validString = "J-H";
        var ExpectedCard = new Hearts(Card.JACK);
        var ActualCard = CardBuilder.fromString(validString);

        Assert.AreEqual(ExpectedCard, ActualCard);
    }
Ejemplo n.º 8
0
 // Use this for initialization
 void Start()
 {
     player   = GameObject.Find("Player");
     nextFire = fireDist;
     lastPos  = player.transform.position;
     hearts   = (Hearts)GameObject.Find("Hearts").GetComponent(typeof(Hearts));
     player   = GameObject.Find("Player");
 }
Ejemplo n.º 9
0
    public static Hearts Clamp(Hearts input, Hearts min, Hearts max)
    {
        int total   = input.TotalPoints;
        int clamped = Mathf.Clamp(total, min.TotalPoints, max.TotalPoints);

        input.SetTotalPoints(clamped);
        return(input);
    }
Ejemplo n.º 10
0
 // Use this for initialization
 void Start()
 {
     highest_pos = extent - starting_pos;
     lowest_pos  = highest_pos - extent;
     nextFire    = fireDist;
     hearts      = (Hearts)GameObject.Find("Hearts").GetComponent(typeof(Hearts));
     player      = GameObject.Find("Player");
 }
Ejemplo n.º 11
0
 // Use this for initialization
 void Start()
 {
     hp         = maxHp;
     lifes      = 3;
     lifeCanvas = GameObject.FindObjectOfType <Hearts>();
     lifeCanvas.ChangeLife(lifes);
     //anim = GetComponent<Animator>();
     soundSource = GetComponent <AudioSource>();
 }
Ejemplo n.º 12
0
 // Use this for initialization
 void Start()
 {
     Debug.Log("bullet start");
     // must do this otherwise new bullets don't cause damage
     hearts  = (Hearts)GameObject.Find("Hearts").GetComponent(typeof(Hearts));
     rb      = GetComponent <Rigidbody2D>();
     target  = GameObject.FindGameObjectWithTag("Player").transform;
     moveDir = (target.transform.position - transform.position).normalized * maxSpeed;
 }
Ejemplo n.º 13
0
 public GuiManager(ContentManager content, Texture2D defaultTex)
 {
     _playerHearts          = new Hearts(content.Load <Texture2D>("gui/hearts"));
     _playerDamageIndicator = new DamageIndicator(defaultTex)
     {
         Color     = new Color(100, 0, 0, 100),
         Position  = Vector2.Zero,
         Rectangle = new Rectangle(0, 0, Game1.ScreenWidth, Game1.ScreenHeight)
     };
 }
Ejemplo n.º 14
0
    public void FetchNewValue()
    {
        if (currentHearts == currentHp.Value)
        {
            return;
        }
        prevHearts    = currentHearts;
        currentHearts = currentHp.Value;

        // Debug.Log("Fetched new value. Prev hearts and current hearts: " + prevHearts + " " + currentHearts);
    }
Ejemplo n.º 15
0
    // Start is called before the first frame update
    void Start()
    {
        // Assigns rigidbody of gameobject to rb
        rb         = GetComponent <Rigidbody2D>();
        m_Collider = GetComponent <PolygonCollider2D>();

        //l_Text = GameObject.Find("LivesText").GetComponent<Text>();
        //DisplayLives();

        hearts = GameObject.FindObjectOfType <Hearts>();
    }
Ejemplo n.º 16
0
    public static Hearts operator-(Hearts left, int right)
    {
        Hearts newHP     = new Hearts();
        int    newPoints = left.TotalPoints - right;

        if (newPoints < 0)
        {
            newPoints = 0;
        }
        newHP.Recalculate(newPoints);
        return(newHP);
    }
Ejemplo n.º 17
0
 public void Heal(Hearts amount)
 {
     if (!enabled)
     {
         return;
     }
     ActualHp += amount;
     ActualHp  = Hearts.Clamp(ActualHp, 0, maxHearts.Value);
     if (onHealed != null)
     {
         onHealed.Invoke(amount.TotalPoints);
     }
 }
Ejemplo n.º 18
0
 // Use this for initialization
 void Start()
 {
     instance       = this;
     dissolved      = new bool[hearts.Length];
     need_dissolved = new bool[hearts.Length];
     need_grow      = new bool[hearts.Length];
     for (int i = 0; i < hearts.Length; i++)
     {
         dissolved[i]      = true;
         need_dissolved[i] = false;
         need_grow[i]      = true;
     }
 }
Ejemplo n.º 19
0
 void Start()
 {
     animator       = transform.GetComponent <Animator> ();
     lastFireTime   = Time.time;
     iceCream       = ((GameObject)Resources.Load("GameObjects/IceCream/IceCream", typeof(GameObject))).transform;
     iceCreamPuddle = ((GameObject)Resources.Load("GameObjects/IceCreamPuddle/IceCreamPuddle", typeof(GameObject))).transform;
     mainCamera     = GameObject.FindGameObjectWithTag("MainCamera").transform;
     energyBar      = transform.Find("Bar").GetComponent <Bar>();
     hearts         = transform.Find("Hearts").GetComponent <Hearts>();
     ui             = GameObject.FindGameObjectWithTag("UI").GetComponent <UI> ();
     ApplyHat();
     ApplyHair();
     ApplySkin();
 }
Ejemplo n.º 20
0
        public override bool Equals(object other)
        {
            if (other == null || other.GetType() != GetType())
            {
                return(false);
            }

            var otherRecipe = (Recipe)other;

            return(Type.Equals(otherRecipe.Type) &&
                   Name.Equals(otherRecipe.Name) &&
                   Hearts.Equals(otherRecipe.Hearts) &&
                   Effects.OrderBy(e => e).SequenceEqual(otherRecipe.Effects.OrderBy(e => e)) &&
                   Ingredients.OrderBy(i => i).SequenceEqual(otherRecipe.Ingredients.OrderBy(i => i)));
        }
Ejemplo n.º 21
0
 public void Dispose()
 {
     Heart?.Dispose();
     Hearts?.Dispose();
     Stage?.Dispose();
     PenguinSliding?.Dispose();
     PenguinWalking?.Dispose();
     PenguinWithBoard?.Dispose();
     UIBackground?.Dispose();
     Grzesiek?.Dispose();
     DOG?.Dispose();
     Alex?.Dispose();
     Kamil?.Dispose();
     Marcin?.Dispose();
     Marek?.Dispose();
     Tymon?.Dispose();
     PenguinIcons?.Dispose();
 }
Ejemplo n.º 22
0
    public void HandleShowResult(ShowResult result)
    {
        switch (result)
        {
        case ShowResult.Finished:
            heart = GameObject.FindGameObjectWithTag("Hearts").GetComponent <Hearts>() as Hearts;
            heart.AddHeart();
            Debug.Log("<color=green>The ad was skipped before reaching the end.</color>");
            break;

        case ShowResult.Skipped:
            Debug.Log("<color=yellow>The ad was skipped before reaching the end.</color>");
            break;

        case ShowResult.Failed:
            Debug.LogError("<color=red>The ad failed to be shown.</color>");
            break;
        }
    }
Ejemplo n.º 23
0
        public static void SaveStore()
        {
            WebGLJump.SaveData(SaveKeys.Money, Money.ToString());
            WebGLJump.SaveData(SaveKeys.Hearts, Hearts.ToString());
            WebGLJump.SaveData(SaveKeys.Armor, Armor.ToString());
            WebGLJump.SaveData(SaveKeys.Healing, Healing.ToString());

            for (int i = 0; i < GunOwned.Length; ++i)
            {
                WebGLJump.SaveData(SaveKeys.GunOwned + i.ToString(), GunOwned[i].ToString());
            }
            for (int i = 0; i < GunPower.Length; ++i)
            {
                WebGLJump.SaveData(SaveKeys.GunPower + i.ToString(), GunPower[i].ToString());
            }
            for (int i = 0; i < GunEquipped.Length; ++i)
            {
                WebGLJump.SaveData(SaveKeys.GunEquipped + i.ToString(), GunEquipped[i].ToString());
            }
        }
Ejemplo n.º 24
0
    void FindGameObjects()
    {
        GameObject go = GameObject.Find("Score");

        if (go != null)
        {
            scoreDisplay = go.GetComponent <Text>();
        }

        go = GameObject.Find("HiScore");
        if (go != null)
        {
            hiScoreDisplay = go.GetComponent <Text>();
        }

        go = GameObject.Find("Hearts");
        if (go != null)
        {
            hearts = go.GetComponent <Hearts>();
        }
    }
Ejemplo n.º 25
0
    public void spawnPlayer()
    {
        var evnt = PlayerVisibilityChanged.Create(Bolt.GlobalTargets.Others);

        evnt.Player  = player.GetComponent <FirstPersonController>().GetEntity();
        evnt.Visible = true;
        evnt.Send();

        player.SetActive(true);
        player.GetComponent <FirstPersonController>().bindMouse();
        activate_ALIVE_UI();
        ArmorAndWeapons armor   = ArmorUI.GetComponent <ArmorAndWeapons>();
        Stamina         stamina = StaminaUI.GetComponent <Stamina>();
        Hearts          health  = HealthUI.GetComponent <Hearts>();
        WeaponControl   weapons = EquipmentUI.GetComponent <WeaponControl>();

        armor.resetArmor();
        stamina.resetStamina();
        health.resetHealth();
        weapons.onSpawn();
        player.transform.position = randomSpawnpoint();
    }
Ejemplo n.º 26
0
    public void Refresh(Hearts displayedValue)
    {
        for (int i = 0; i < hearts.Count; i++)
        {
            var heart = hearts[i];
            heart.gameObject.SetActive(i < maxHp.Value.hearts);
            if (!heart.isActiveAndEnabled)
            {
                continue;
            }

            // if this is the last heart, show fractions
            if (i == displayedValue.hearts && displayedValue.fractions > 0)
            {
                heart.fraction = displayedValue.fractions;
            }

            // otherwise, show full / empty hearts
            else
            {
                heart.filled = i < displayedValue.hearts;
            }
        }
    }
Ejemplo n.º 27
0
	void Awake(){
		Instance = this;
	}
 void Start()
 {
     player = playerComp.GetComponent<PlayerController>();
     hearts = heartsComp.GetComponent<Hearts>();
 }
Ejemplo n.º 29
0
 void Subtract()
 {
     value -= 1;
 }
Ejemplo n.º 30
0
 void AddInput()
 {
     value += input;
 }
Ejemplo n.º 31
0
 void SubtractInput()
 {
     value -= input;
 }
Ejemplo n.º 32
0
 void SetValue(int qty)
 {
     value = qty;
 }
Ejemplo n.º 33
0
	// Use this for initialization
	void Start () {
        m_Health = m_MaxHealth;
        m_Heart = GameObject.Find("Hearts").GetComponent<Hearts>();
	}
Ejemplo n.º 34
0
 public void DoDamage(Hearts amount)
 {
     DoDamage(amount, transform.position + Vector3.back * .25f, Vector3.forward);
 }