Beispiel #1
0
    public void EffectToTimeObject(float spawnTime, CardEffect effect)
    {
        List <CardEffect> effectStack   = handEffects[GameManager.GlobalTimeToTurn(spawnTime)];
        float             shotSpeed     = effect.shotSpeed;
        float             shotFrequency = effect.shotFrequency;
        int   shotCount  = effect.shotCount;
        float shotSpread = effect.shotSpread;

        for (int i = 0; i < effectStack.Count; i++)
        {
            //shotSpeed += effectStack[i].shotSpeed
            shotFrequency += effectStack[i].shotFrequencyModifier;
            shotCount     += effectStack[i].shotCountModifier;
            shotSpread    += effectStack[i].shotSpreadModifier;
        }
        for (int i = 0; i < effectStack.Count; i++)
        {
            //shotSpeed += effectStack[i].shotSpeed
            shotFrequency *= effectStack[i].shotFrequencyScalar;
            shotCount      = (int)((float)shotCount * effectStack[i].shotCountScalar);
            shotSpread    *= effectStack[i].shotSpreadScalar;
        }

        int   length        = (int)shotFrequency * effect.def.cost;
        float freqIncrement = (float)effect.def.cost / (float)length;

        for (int r = 0; r < length; r++)
        {
            float freqDelta = (freqIncrement * r) * UISkillBar.tabTimeIncrement;

            float angleStart     = -shotSpread;
            float totalAngle     = shotSpread * 2;
            float angleIncrement = totalAngle / (shotCount - 1);
            for (int i = 0; i < effect.shotCount; i++)
            {
                CardTimeObject obj = GameObject.Instantiate <CardTimeObject>(effect.def.projectilePrefab, GameManager.instance.transform);

                if (shotCount > 1)
                {
                    float angle = angleStart + (angleIncrement * i);
                    obj.dir = new Vector3(
                        Mathf.Cos(Mathf.Deg2Rad * angle),
                        -Mathf.Sin(Mathf.Deg2Rad * angle),
                        0);
                }
                else
                {
                    obj.dir = Vector3.right;
                }

                obj.scheduledDeathTime = effect.duration * GameManager.instance.turnLength;
                obj.spawnTime          = freqDelta + spawnTime + ((float)i) * 0.05f;
                obj.prebirthSpawnTime  = spawnTime - Mathf.Epsilon;
                obj.parentAgeAtBirth   = GameManager.instance.player.t;
                obj.Init(GameManager.instance.player.evaluable, effect);
                PewParticleLogic.PlacePew(GameManager.instance.player.evaluable, obj.spawnTime, obj.prebirthSpawnTime);
                timeObjectList.Add(obj);
            }
        }
    }
Beispiel #2
0
    private void EffectToPetTimeObject(float spawnTime, CardEffect effect)
    {
        CardTimeObject obj = GameObject.Instantiate <CardTimeObject>(effect.def.projectilePrefab, GameManager.instance.transform);

        obj.scheduledDeathTime = effect.duration * GameManager.instance.turnLength;
        obj.spawnTime          = spawnTime;
        obj.prebirthSpawnTime  = spawnTime - Mathf.Epsilon;
        obj.parentAgeAtBirth   = GameManager.instance.player.t;
        obj.Init(GameManager.instance.player.evaluable, effect);
        timeObjectList.Add(obj);
    }