Esempio n. 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);
            }
        }
    }
Esempio n. 2
0
 private void StartDeath()
 {
     GameManager.ChangeState(GameState.IS_DYING);
     diedAt  = GameManager.time;
     isDying = true;
     PewParticleLogic.PlaceBoom(GameManager.instance.player.evaluable, diedAt, diedAt - Mathf.Epsilon);
     Debug.Log("You are dying!");
 }
Esempio n. 3
0
    public static PewParticleLogic PlacePew(IEvaluable parent, float birthTime, float?prebirthSpawnTime)
    {
        PewParticleLogic ppl = Instantiate(Resources.Load <PewParticleLogic>("Pew")) as PewParticleLogic;

        ppl.Init(parent);
        ppl.spawnTime         = birthTime;
        ppl.prebirthSpawnTime = prebirthSpawnTime;
        return(ppl);
    }