Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        var moveAmt = Input.GetAxis("Horizontal") * MOVE_SPEED * Time.deltaTime;

        if (moveAmt == 0)
        {
            this.rend.materials[0].mainTexture = stableShip;
        }
        else if (moveAmt > 0)
        {
            this.rend.materials[0].mainTexture = rightShip;
        }
        else
        {
            this.rend.materials[0].mainTexture = leftShip;
        }

        var pos = this.trans.position;

        pos.x += moveAmt;
        this.trans.position = pos;

        if (Input.GetMouseButtonDown(0) || Input.GetKeyDown(KeyCode.Space))
        {
            var spawnPos = this.trans.position;
            spawnPos.z += 15;

            if (!string.IsNullOrEmpty(customEventName) && LevelSettings.CustomEventExists(customEventName))
            {
                LevelSettings.FireCustomEvent(customEventName, this.trans);
            }
            PoolBoss.SpawnOutsidePool(ProjectilePrefab.transform, spawnPos, ProjectilePrefab.transform.rotation);
        }
    }
Exemplo n.º 2
0
        // OnStateExit is called when a transition ends and the state machine finishes evaluating this state
        public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
        {
            if (fireExitEvent && ExitCustomEvent != LevelSettings.NoEventName && !string.IsNullOrEmpty(ExitCustomEvent))
            {
                LevelSettings.FireCustomEvent(ExitCustomEvent, _actorTrans);
            }

            if (fireMultiAnimTimeEvent)
            {
                _playMultiEvent1 = true;
                _playMultiEvent2 = true;
                _playMultiEvent3 = true;
                _playMultiEvent4 = true;
            }
        }
Exemplo n.º 3
0
        // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
        public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
        {
            _lastRepetition = 0;

            _actorTrans = ActorTrans(animator);

            if (!fireEnterEvent)
            {
                return;
            }

            if (EnterCustomEvent == LevelSettings.NoEventName || string.IsNullOrEmpty(EnterCustomEvent))
            {
                return;
            }

            LevelSettings.FireCustomEvent(EnterCustomEvent, _actorTrans);
        }
Exemplo n.º 4
0
        // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
        override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
        {
            var animRepetition = (int)stateInfo.normalizedTime;
            var animTime       = stateInfo.normalizedTime - animRepetition;

            if (!fireAnimTimeEvent)
            {
                goto multievent;
            }

            #region Timed to Anim
            if (!fireEnterEvent && RetriggerWhenStateLoops)
            {
                // change back to true if "re-trigger" checked and anim has looped.

                if (_lastRepetition >= 0 && animRepetition > _lastRepetition)
                {
                    fireEnterEvent = true;
                }
            }

            if (fireEnterEvent)
            {
                if (animTime > whenToFireEvent)
                {
                    fireEnterEvent = false;

                    LevelSettings.FireCustomEvent(timedCustomEvent, _actorTrans);
                }
            }

            #endregion

multievent:

            if (!fireMultiAnimTimeEvent)
            {
                goto afterMulti;
            }

            #region Fire Multiple Events Timed To Anim

            if (RetriggerWhenStateLoops)
            {
                if (!_playMultiEvent1)
                {
                    // change back to true if "re-trigger" checked and anim has looped.
                    if (_lastRepetition >= 0 && animRepetition > _lastRepetition)
                    {
                        _playMultiEvent1 = true;
                    }
                }
                if (!_playMultiEvent2)
                {
                    // change back to true if "re-trigger" checked and anim has looped.
                    if (_lastRepetition >= 0 && animRepetition > _lastRepetition)
                    {
                        _playMultiEvent2 = true;
                    }
                }
                if (!_playMultiEvent3)
                {
                    // change back to true if "re-trigger" checked and anim has looped.
                    if (_lastRepetition >= 0 && animRepetition > _lastRepetition)
                    {
                        _playMultiEvent3 = true;
                    }
                }
                if (!_playMultiEvent4)
                {
                    // change back to true if "re-trigger" checked and anim has looped.
                    if (_lastRepetition >= 0 && animRepetition > _lastRepetition)
                    {
                        _playMultiEvent4 = true;
                    }
                }
            }

            if (!_playMultiEvent1)
            {
                goto decideMulti2;
            }
            if (animTime < whenToStartMultiEvent1 || numOfMultiEventsToFire < 1)
            {
                goto decideMulti2;
            }

            _playMultiEvent1 = false;
            LevelSettings.FireCustomEvent(MultiTimedEvent, _actorTrans);

decideMulti2:

            if (!_playMultiEvent2)
            {
                goto decideMulti3;
            }

            if (animTime < whenToStartMultiEvent2 || numOfMultiEventsToFire < 2)
            {
                goto decideMulti3;
            }

            _playMultiEvent2 = false;
            LevelSettings.FireCustomEvent(MultiTimedEvent, _actorTrans);

decideMulti3:

            if (!_playMultiEvent3)
            {
                goto decideMulti4;
            }

            if (animTime < whenToStartMultiEvent3 || numOfMultiEventsToFire < 3)
            {
                goto decideMulti4;
            }

            _playMultiEvent3 = false;
            LevelSettings.FireCustomEvent(MultiTimedEvent, _actorTrans);

decideMulti4:

            if (!_playMultiEvent4)
            {
                goto afterMulti;
            }

            if (animTime < whenToStartMultiEvent4 || numOfMultiEventsToFire < 4)
            {
                goto afterMulti;
            }

            _playMultiEvent4 = false;
            LevelSettings.FireCustomEvent(MultiTimedEvent, _actorTrans);

            #endregion

afterMulti:

            _lastRepetition = animRepetition;
        }