Beispiel #1
0
 /// <summary>
 /// Stops the flame.
 /// </summary>
 private void StopFiring()
 {
     // if we are running a constant effect like wall of fire, stop it now
     if (flamethrowerScript != null && flamethrowerScript.Duration > 10000)
     {
         flamethrowerScript.Stop();
     }
     flamethrowerObject = null;
     flamethrowerScript = null;
 }
Beispiel #2
0
 private void Awake()
 {
     // find a point light
     firePointLight = gameObject.GetComponentInChildren<Light>();
     if (firePointLight != null)
     {
         // we have a point light, set the intensity to 0 so it can fade in nicely
         lightIntensity = firePointLight.intensity;
         firePointLight.intensity = 0.0f;
         baseY = firePointLight.gameObject.transform.position.y;
     }
     seed = UnityEngine.Random.value * Seed;
     fireBaseScript = gameObject.GetComponent<FireBaseScript>();
 }
Beispiel #3
0
    public void BeginEffect()
    {
        Vector3    pos;
        float      yRot     = transform.rotation.eulerAngles.y;
        Vector3    forwardY = Quaternion.Euler(0.0f, yRot, 0.0f) * Vector3.forward;
        Vector3    forward  = transform.forward;
        Vector3    right    = transform.right;
        Vector3    up       = transform.up;
        Quaternion rotation = Quaternion.identity;

        currentPrefabObject = GameObject.Instantiate(currentPrefab);
        currentPrefabScript = currentPrefabObject.GetComponent <FireConstantBaseScript>();

        if (currentPrefabScript == null)
        {
            // temporary effect, like a fireball
            currentPrefabScript = currentPrefabObject.GetComponent <FireBaseScript>();
            if (currentPrefabScript.IsProjectile)
            {
                // set the start point near the player
                rotation = transform.rotation;
                pos      = transform.position;
            }
            else
            {
                // set the start point in front of the player a ways
                pos = transform.position + (forwardY * 10.0f);
            }
        }
        else
        {
            // set the start point in front of the player a ways, rotated the same way as the player
            pos      = transform.position - (forwardY * 5.0f);
            rotation = transform.rotation;
            pos.y    = 0.0f;
        }


        currentPrefabObject.transform.position = pos;
        currentPrefabObject.transform.rotation = rotation;
    }
Beispiel #4
0
    /// <summary>
    /// Begin the flamethrower.
    /// </summary>
    private void BeginFiring()
    {
        if (currentEnergy <= 0.0f)
        {
            return;
        }

        Vector3    pos;
        float      yRot     = transform.rotation.eulerAngles.y;
        Vector3    forwardY = Quaternion.Euler(0.0f, yRot, 0.0f) * Vector3.forward;
        Vector3    forward  = transform.forward;
        Vector3    right    = transform.right;
        Vector3    up       = transform.up;
        Quaternion rotation = Quaternion.identity;

        flamethrowerObject = GameObject.Instantiate(flamethrowerPrefab);
        flamethrowerScript = flamethrowerObject.GetComponent <FireBaseScript>();

        // temporary effect, like a fireball
        if (flamethrowerScript.IsProjectile)
        {
            rotation = transform.rotation;
            pos      = transform.position;
        }
        else
        {
            pos = transform.position + (forwardY * 10.0f);
        }

        FireProjectileScript projectileScript = flamethrowerObject.GetComponentInChildren <FireProjectileScript>();

        if (projectileScript != null)
        {
            // make sure we don't collide with other friendly layers
            projectileScript.ProjectileCollisionLayers &= (~UnityEngine.LayerMask.NameToLayer("FriendlyLayer"));
        }

        flamethrowerObject.transform.position = pos;
        flamethrowerObject.transform.rotation = rotation;
    }
 private void StopCurrent()
 {
     // if we are running a constant effect like wall of fire, stop it now
     if (currentPrefabScript != null && currentPrefabScript.Duration > 10000)
     {
         currentPrefabScript.Stop();
     }
     currentPrefabObject = null;
     currentPrefabScript = null;
 }
    private void BeginEffect()
    {
        Vector3 pos;
        float yRot = transform.rotation.eulerAngles.y;
        //Vector3 forwardY = Quaternion.Euler(0.0f, yRot, 0.0f) * Vector3.forward;
        Vector3 forwardY = new Vector3(0, 0, 0);
        Vector3 forward = transform.forward;
        Vector3 right = transform.right;
        Vector3 up = transform.up;
        Quaternion rotation = Quaternion.identity;
        currentPrefabObject = GameObject.Instantiate(Prefabs[currentPrefabIndex]);
        currentPrefabScript = currentPrefabObject.GetComponent<FireConstantBaseScript>();

        switch (Convert.ToInt32(yRot))
        {
            case 0:
                forwardY = new Vector3(0, 0, 1);
                break;
            case 90:
                forwardY = new Vector3(1, 0, 0);
                break;
            case 180:
                forwardY = new Vector3(0, 0, -1);
                break;
            case 270:
                forwardY = new Vector3(-1, 0, 0);
                break;
            default:
                break;

        }

        if (currentPrefabScript == null)
        {
            // temporary effect, like a fireball
            currentPrefabScript = currentPrefabObject.GetComponent<FireBaseScript>();
            if (currentPrefabScript.IsProjectile)
            {
                // set the start point near the player
                rotation = transform.rotation;
                pos = SpellSpawnPoint.transform.position;

            }
            else
            {
                // set the start point in front of the player a ways
                if (currentPrefabObject.name.Contains("Strike"))
                {

                    pos = DevestationSpellSpwanPoint.transform.position;
                }
                else
                {
                    pos = transform.position + (forwardY * 10.0f);

                }

            }
        }
        else
        {
            // set the start point in front of the player a ways, rotated the same way as the player
            pos = transform.position + (forwardY * 5.0f);
            rotation = transform.rotation;
            pos.y = 0.0f;
        }

        FireProjectileScript projectileScript = currentPrefabObject.GetComponentInChildren<FireProjectileScript>();
        if (projectileScript != null)
        {
            // make sure we don't collide with other friendly layers
            projectileScript.ProjectileCollisionLayers &= (~UnityEngine.LayerMask.NameToLayer("FriendlyLayer"));
        }

        currentPrefabObject.transform.position = pos;
        currentPrefabObject.transform.rotation = rotation;
    }
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
    //below for magician
    void AttackByFire(int skillNum)
    {
        if (skillNum == 1)
        {
            if (!pa.ConsumeMP(20))
            {
                return;
            }
        }
        else if (skillNum == 2)
        {
            if (!pa.ConsumeMP(50))
            {
                return;
            }
        }
        Vector3    pos;
        float      yRot     = transform.rotation.eulerAngles.y;
        Vector3    forwardY = Quaternion.Euler(0.0f, yRot, 0.0f) * Vector3.forward;
        Vector3    forward  = transform.forward;
        Vector3    right    = transform.right;
        Vector3    up       = transform.up;
        Quaternion rotation = Quaternion.identity;

        currentPrefabObject = GameObject.Instantiate(Prefabs[skillNum]);
        currentPrefabScript = currentPrefabObject.GetComponent <FireConstantBaseScript>();

        if (currentPrefabScript == null)
        {
            // temporary effect, like a fireball
            currentPrefabScript = currentPrefabObject.GetComponent <FireBaseScript>();
            if (currentPrefabScript.IsProjectile)
            {
                // set the start point near the player
                rotation = transform.rotation;
                pos      = transform.position + forward + right + up;
            }
            else
            {
                // set the start point in front of the player a ways
                pos = transform.position + (forwardY * 10.0f);
            }
        }
        else
        {
            // set the start point in front of the player a ways, rotated the same way as the player
            pos      = transform.position + (forwardY * 5.0f);
            rotation = transform.rotation;
            pos.y    = 0.0f;
        }

        FireProjectileScript projectileScript = currentPrefabObject.GetComponentInChildren <FireProjectileScript>();

        if (projectileScript != null)
        {
            // make sure we don't collide with other fire layers
            projectileScript.ProjectileCollisionLayers &= (~UnityEngine.LayerMask.NameToLayer("FireLayer"));
        }

        currentPrefabObject.transform.position = pos;
        currentPrefabObject.transform.rotation = rotation;
    }