/**
     * Highlights the elements from the queue in the GUI
     *
     * Example call:
     * SelectElement(Elements.fire, true)
     */
    void HighlightElementSelection(Elements.elemEnum elem, bool isSelect)
    {
        GameObject highlightGameObject = elementToSelectorGameObjectDict[elem];

        if (highlightGameObject != null)
        {
            highlightGameObject.SetActive(isSelect);
        }
    }
 /**
  * Add element to the element queue.
  * Max 2 elements; adding element when the queue
  * has 2 already results in removal of the least
  * recently added element.
  *
  * Example call:
  * Call this with QueueElement(Elements.fire)
  * Where Elements is the Element.elemEnum
  **/
 void QueueElement(Elements.elemEnum elem)
 {
     // Remove all elements if there are two already
     if (elemsSelected.getNumAssignedElements() == 2)
     {
         clearCurrentSelectedElements();
     }
     elemsSelected.pushIfPossibleElseClearAndPush(elem);
     HighlightElementSelection(elem, true);
 }
Beispiel #3
0
 public void pushIfPossibleElseClearAndPush(Elements.elemEnum element)
 {
     if (this.first == Elements.elemEnum.none)
     {
         this.first = element;
     }
     else if (this.second == Elements.elemEnum.none)
     {
         this.second = element;
     }
     else
     {
         clear();
         this.first = element;
     }
 }
 // todo: make enum for elements & use it
 // Decrement the elements by the specified amount
 public void DecrementElement(Elements.elemEnum element, int amount)
 {
     if (element == Elements.elemEnum.fire)
     {
         fireLevelController.DecrementElement(amount);
     }
     else if (element == Elements.elemEnum.water)
     {
         waterLevelController.DecrementElement(amount);
     }
     else if (element == Elements.elemEnum.earth)
     {
         earthLevelController.DecrementElement(amount);
     }
     else if (element == Elements.elemEnum.wind)
     {
         windLevelController.DecrementElement(amount);
     }
 }
Beispiel #5
0
    public void takeDamage(int damage, Elements.elemEnum firstElement, Elements.elemEnum secondElement)
    {
        MonsterHealth -= damage * damageMultiplier(firstElement) * damageMultiplier(secondElement);

        HealthBar.fillAmount = MonsterHealth / MonsterStartHealth;

        checkDead();

        // Animate the damage taking and stagger according to damage threshold
        if (!dead && anim != null)
        {
            anim.SetTrigger("TakeDamage");
            if (damage >= staggerThreshold)
            {
                agent.Stop();
                staggered = true;
                StartCoroutine(resumeMovementPostAnimation());
            }
        }
    }
Beispiel #6
0
 public float damageMultiplier(Elements.elemEnum element)
 {
     if (element == Elements.elemEnum.fire)
     {
         return((100f - fireResistance) / 100f);
     }
     else if (element == Elements.elemEnum.water)
     {
         return((100f - waterResistance) / 100f);
     }
     else if (element == Elements.elemEnum.earth)
     {
         return((100f - fireResistance) / 100f);
     }
     else if (element == Elements.elemEnum.wind)
     {
         return((100f - windResistance) / 100f);
     }
     else
     {
         return(1f);
     }
 }
Beispiel #7
0
    private void CastSpell(Hands.handEnum hand)
    {
        ElementsPair elementPair;
        GameObject   bulletPoint;

        if (hand == Hands.handEnum.left)
        {
            elementPair           = spellController.LeftHandElementsPair;
            bulletPoint           = LeftBulletPoint;
            nextSpellCooldownLeft = Time.time + 0.5f;
        }
        else if (hand == Hands.handEnum.right)
        {
            elementPair            = spellController.RightHandElementsPair;
            bulletPoint            = RightBulletPoint;
            nextSpellCooldownRight = Time.time + 0.5f;
        }
        else
        {
            Debug.Log("[CastingControl][CastSpell] Error: inappropriate hand is provided - " + hand);
            return;
        }

        if (elementPair.isNonePair())
        {
            return;
        }


        Spells.spellEnum    spellEnum   = Spells.elementsPairToSpellEnum[elementPair];
        Spells.SpellDetails spellDetail = spellEnumToSpellDetails[spellEnum];

        bool shouldCreateBullet = spellController;
        // === setup done. shoot out bullet

        Vector3 pos      = bulletPoint.transform.position;
        Vector3 rotation = new Vector3(0, 0, 0);

        prefabScript = spellDetail.spellObject.GetComponent <FireConstantBaseScript>();

        if (prefabScript == null)
        {
            // temporary effect, like a fireball
            prefabScript = spellDetail.spellObject.GetComponent <FireBaseScript>();
            if (spellDetail.spellObject.GetComponent <FireBaseScript>().IsProjectile)
            {
                // set the start point near the hand
                rotation = cam.transform.rotation.eulerAngles;
            }
        }
        else
        {
            // TODO: Not sure if this way of checking for spell type is good idea. Maybe it is better to add "isProjectile" variable to Spells, but w/e
            // set the start point in front of the player a ways, rotated the same way as the player
            RaycastHit hit;

            pos        = bulletPoint.transform.position;
            rotation   = cam.transform.rotation.eulerAngles;
            rotation.x = 0; // this sets the spell up virtically
            pos.y      = 0.0f;

            Physics.Raycast(bulletPoint.transform.position, cam.transform.forward, out hit, 9000000f, laycastLayerMask);
            if (hit.collider == null)
            {
                shouldCreateBullet = false;
            }

            pos = hit.point;
        }

        if (shouldCreateBullet && spellController.hasEnoughResourceToCast(elementPair, spellDetail.firstElementCost, spellDetail.secondElementCost))
        {
            var spellPrefab = GameObject.Instantiate(spellDetail.spellObject, pos, Quaternion.Euler(rotation));

            Elements.elemEnum curSecondElement = elementPair.Second; // this is because "DecrementElement" may modify this
            spellController.DecrementElement(elementPair.First, spellDetail.firstElementCost);
            spellController.DecrementElement(curSecondElement, spellDetail.secondElementCost);
        }
    }
Beispiel #8
0
 public void clear()
 {
     this.first  = Elements.elemEnum.none;
     this.second = Elements.elemEnum.none;
 }
Beispiel #9
0
 public bool containsElement(Elements.elemEnum element)
 {
     return(this.first == element || this.second == element);
 }
Beispiel #10
0
 public ElementsPair(Elements.elemEnum first, Elements.elemEnum second)
 {
     this.first  = first;
     this.second = second;
 }