// Use this for initialization
 void Awake()
 {
     anim             = GetComponent <Animator>();
     currentHealth    = startingHealth;
     sprite           = GetComponent <SpriteRenderer>();
     originalMaterial = sprite.material;
     rigidbody        = GetComponent <Rigidbody2D>();
     movementScript   = GetComponent <PlayerMovement2>();
     elementScript    = GetComponent <ElementalEffects>(); //Pick up the element of the player
 }
示例#2
0
        public void Death()
        {
            foreach (var e in ElementalEffects)
            {
                e.Removed();
            }

            ElementalEffects.Clear();
            TimedModifierStack.Clear();

            UpdateFinalStats();
        }
示例#3
0
    // Use this for initialization
    void Start()      //Get player attack object and element attached to it
    {
        player = GameObject.FindGameObjectWithTag("Player");

        foreach (Transform child in player.transform)
        {
            if (child.tag == "Player Attack")
            {
                playerWeapon  = child.gameObject;
                elementScript = child.GetComponent <ElementalEffects>();
            }
        }
    }
示例#4
0
        /// <summary>
        ///   Add an elemental effect to the StatSystem. Elemental Effect does not stack, adding the same type (the Equals
        ///   return true) will instead replace the old one with the new one.
        /// </summary>
        /// <param name="effect"></param>
        public void AddElementalEffect(BaseElementalEffect effect)
        {
            effect.Applied(_owner);

            var replaced = false;

            for (var i = 0; i < ElementalEffects.Count; ++i)
            {
                if (effect.Equals(ElementalEffects[i]))
                {
                    replaced = true;
                    ElementalEffects[i].Removed();
                    ElementalEffects[i] = effect;
                }
            }

            if (!replaced)
            {
                ElementalEffects.Add(effect);
            }
        }
示例#5
0
        public void Tick(float deltaTime)
        {
            var needUpdate = false;

            for (var i = 0; i < TimedModifierStack.Count; ++i)
            {
                //permanent modifier will have a timer == -1.0f, so jump over them
                if (TimedModifierStack[i].timer > 0.0f)
                {
                    TimedModifierStack[i].timer -= deltaTime;
                    if (TimedModifierStack[i].timer <= 0.0f)
                    {
                        //modifier finished, so we remove it from the stack
                        TimedModifierStack.RemoveAt(i);
                        i--;
                        needUpdate = true;
                    }
                }
            }

            if (needUpdate)
            {
                UpdateFinalStats();
            }

            for (var i = 0; i < ElementalEffects.Count; ++i)
            {
                var effect = ElementalEffects[i];
                effect.Tick(this);

                if (effect.Done)
                {
                    ElementalEffects[i].Removed();
                    ElementalEffects.RemoveAt(i);
                    i--;
                }
            }
        }
示例#6
0
    public int destroyElement; //Element that will destroy this object

    // Use this for initialization
    void Start()
    {
        elementScript = gameObject.GetComponent <ElementalEffects>();
    }
 // Use this for initialization
 void Start()
 {
     player = GameObject.FindGameObjectWithTag("Player");
     playerElementScript = player.GetComponent <ElementalEffects>(); //Pick up the element of the player
     elementalScript     = GetComponent <ElementalEffects>();
 }
 // Use this for initialization
 void Start()
 {
     elementScript       = gameObject.GetComponent <ElementalEffects>();
     attackElementScript = transform.parent.GetComponentInChildren <ElementalEffects>(); //Pick up the element of the first child on the Player object, this should be the atk hitbox
 }