Exemple #1
0
    void Start()
    {
        filterList   = new List <Filter[]>();
        zapStateList = new List <List <ZapState> > ();
        cameraList   = FindObjectsOfType <Camera>();
        int c = 0;

        foreach (Camera camera in cameraList)
        {
            filterList.Add(camera.GetComponentsInChildren <Filter>(true));
            zapStateList.Add(new List <ZapState>());
            int f = 0;
            // foreach (Filter filter in filterList[c]) {
            while (f < filterList[c].Length)
            {
                ZapState zapState = new ZapState(c, f);
                // if (filter.always) {
                //  zapState.shouldAdd = false;
                //  zapState.shouldClear = false;
                // }
                zapStateList[c].Add(zapState);
                ++f;
            }
            ++c;
        }
    }
Exemple #2
0
        private ZapState GetZapState(Duck duck)
        {
            ZapState state;

            if (zapState.TryGetValue(duck, out state))
            {
                return(state);
            }

            state          = new ZapState();
            zapState[duck] = state;
            return(state);
        }
    // Update is called once per frame
    void Update()
    {
        if (nodeExtend)
        {
            nodeExtend = false;
        }
        if (nodesDie)
        {
            nodesDie = false;
        }

        if (state == ZapState.Idle && zapCount > zapTime)
        {
            foreach (Zapper zap in zaps)
            {
                zap.Zap();
            }
            zapCount = 0f;
            state    = ZapState.Seeking;
        }
        else if (state == ZapState.Idle)
        {
            zapCount += Time.deltaTime;
        }

        if (state == ZapState.Seeking && nodeStepCount >= nodeSteps)
        {
            state         = ZapState.Idle;
            nodeStepCount = 0;
            nodesDie      = true;
        }
        else if (state == ZapState.Seeking && nodeCount > nodeTime)
        {
            nodeExtend = true;
            nodeCount  = 0f;
            nodeStepCount++;
        }
        else if (state == ZapState.Seeking)
        {
            nodeCount += Time.deltaTime;
        }

        /*
         * if (state == ZapState.Striking && strikeCount > strikeTime) {
         *  state = ZapState.Idle;
         *  strikeCount = 0f;
         * }
         * else if (state == ZapState.Striking)
         *  strikeCount += Time.deltaTime;
         */
    }
Exemple #4
0
    void Shuffle()
    {
        int c = 0;

        // foreach (Camera camera in cameraList) {
        while (c < cameraList.Length)
        {
            Filter[] filters = filterList[c];

            for (int i = filters.Length - 1; i > 0; i--)
            {
                int      j     = (int)Mathf.Floor(Random.Range(0f, 1f) * ((float)i + 1f));
                Filter   temp  = filters[i];
                ZapState tempZ = zapStateList[c][i];
                filters[i]                     = filters[j];
                zapStateList[c][i]             = zapStateList[c][j];
                zapStateList[c][i].indexFilter = j;
                filters[j]                     = temp;
                zapStateList[c][j]             = tempZ;
                zapStateList[c][j].indexFilter = i;
            }

            int f = 0;
            // foreach (Filter filter in filters) {
            while (f < filters.Length)
            {
                ZapState zapState = zapStateList[c][f];
                if (zapState.shouldAdd)
                {
                    // Filter newFilter = camera.gameObject.AddComponent(filter.GetType()) as Filter;
                    // newFilter.enabled = Random.Range(0f, 1f) < 0.5f;
                }
                if (zapState.shouldRumble)
                {
                    Filter currentFilter = filterList[zapState.indexCamera][zapState.indexFilter];
                    currentFilter.Rumble();
                }
                ++f;
            }
            ++c;
        }
    }
Exemple #5
0
    public void Clear()
    {
        int c = 0;

        foreach (Camera camera in cameraList)
        {
            int f = 0;
            filterList[c] = camera.GetComponentsInChildren <Filter>() as Filter[];
            foreach (Filter filter in filterList[c])
            {
                ZapState zapState = zapStateList[c][f];
                if (zapState.shouldClear)
                {
                    Destroy(filter);
                }
                ++f;
            }
            ++c;
        }
    }
Exemple #6
0
        private void DoZapping()
        {
            foreach (KeyValuePair <Duck, ZapState> p in zapState)
            {
                p.Value.Cooldown();
            }

            Vec2     hit;
            IAmADuck duck = Level.current.CollisionRay <IAmADuck>(barrelPosition, barrelPosition + barrelVector * ZapRange, out hit);

            Duck current = duck.ToDuck();

            if (current != null)
            {
                ZapState state = GetZapState(current);

                switch (state.Increase())
                {
                case ZapResult.Slowdown:
                    current.vSpeed *= SlowdownFactor;
                    current.hSpeed *= SlowdownFactor;
                    break;

                case ZapResult.Zap:
                    if (!current.dead)
                    {
                        current.Zap(this);
                    }
                    current.Swear();
                    break;

                case ZapResult.Death:
                    current.Destroy(new DTIncinerate(this));
                    state.Clear();
                    break;
                }
            }
        }
Exemple #7
0
 void Start()
 {
     filterList = new List<Filter[]>();
     zapStateList = new List<List<ZapState>> ();
     cameraList = FindObjectsOfType<Camera>();
     int c = 0;
     foreach (Camera camera in cameraList)
     {
         filterList.Add(camera.GetComponentsInChildren<Filter>(true));
         zapStateList.Add(new List<ZapState>());
         int f = 0;
         // foreach (Filter filter in filterList[c]) {
         while (f < filterList[c].Length) {
             ZapState zapState = new ZapState(c, f);
             // if (filter.always) {
             // 	zapState.shouldAdd = false;
             // 	zapState.shouldClear = false;
             // }
             zapStateList[c].Add(zapState);
             ++f;
         }
         ++c;
     }
 }