public void Explode()
 {
     State = AlienStates.Exploding;
     SetCostume("AlienDeath");
     PlaySound("AlienDeath");
     Wait(0.6, GoAway);
 }
 public void Setup(int alienType)
 {
     State = AlienStates.Alive;
     AlienType = alienType;
     SetCostume("Alien" + alienType + "A");
     ScoreValue = alienType * 10;
 }
Exemple #3
0
 public void Setup(int alienType)
 {
     State     = AlienStates.Alive;
     AlienType = alienType;
     SetCostume("Alien" + alienType + "A");
     ScoreValue = alienType * 10;
 }
Exemple #4
0
 public void Explode()
 {
     State = AlienStates.Exploding;
     SetCostume("AlienDeath");
     PlaySound("AlienDeath");
     Wait(0.6, GoAway);
 }
Exemple #5
0
        protected void SetState(AlienStates state)
        {
            canMove       = false;
            _currentState = state;
            Animator.SetTrigger(_animatorTriggers[state]);

            if (_currentState == AlienStates.Run || _currentState == AlienStates.Walk ||
                _currentState == AlienStates.WalkBusy)
            {
                canMove = true;
            }

            if (_currentState == AlienStates.Run)
            {
                speed = RunSpeed;
            }
            else
            {
                speed = WalkSpeed;
            }

            if (_currentState == AlienStates.SittingIdle)
            {
                StartCoroutine(DelaySetRandomState(Random.Range(10.0f, 20.0f)));
            }
        }
Exemple #6
0
    public void ChangeState(AlienStates state)
    {
        if (_state != null)
        {
            _state.Dispose();
            _state = null;
        }

        _state = _stateFactory.CreateState(state);
        _state.Start();
    }
Exemple #7
0
    public AlienState CreateState(AlienStates state)
    {
        switch (state)
        {
        case AlienStates.Waiting:
        {
            return(_waitingFactory.Create());
        }

        case AlienStates.Moving:
        {
            return(_movingFactory.Create());
        }

        case AlienStates.Catched:
        {
            return(_catchedFactory.Create());
        }
        }

        throw Assert.CreateException();
    }
 void GoAway()
 {
     State = AlienStates.Dead;
     Hide();
 }
Exemple #9
0
 void GoAway()
 {
     State = AlienStates.Dead;
     Hide();
 }
Exemple #10
0
        public void Update(GameTime gameTime)
        {
            double deltaTotal = gameTime.ElapsedGameTime.TotalSeconds;

            float speed = 0;
            float turn = 0;

            do
            {
                double delta = deltaTotal;

                if (myPie != null&&state!=AlienStates.EatPie) { state = AlienStates.StartEatPie; }

                //
                // State machine will go here
                //
                switch (state)
                {
                    case AlienStates.Start:
                        state = AlienStates.StanceStart;
                        delta = 0;
                        break;

                    /* Switching you from anything to the stance state */
                    case AlienStates.StanceStart:
                        alien.PlayClip("stance").Speed = 0;
                        state = AlienStates.Stance;
                        location.Y = 0;
                        break;

                    /* You'll be just standing. But if the speed is greater than zero, etner walkstart */
                    case AlienStates.Stance:
                        speed = GetDesiredSpeed(  );
                        turn = GetDesiredTurnRate(  );
                        if (speed > 0)
                        {
                            // We need to leave the stance state and start walking
                            alien.PlayClip("walkstart");
                            alien.Player.Speed = speed;
                            state = AlienStates.WalkLoop;
                        }
                        break;

                    /* Walk loop by editing the speed as necessary */
                    case AlienStates.WalkLoop:
                        //if (state == States.WalkStart) { victoria.PlayClip("lowerbazooka"); }
                        location.Y = 0;
                        if (delta > alien.Player.Clip.Duration - alien.Player.Time)
                        {
                            delta = alien.Player.Clip.Duration - alien.Player.Time;

                            // The clip is done after this update
                            state = AlienStates.WalkLoopStart;
                        }
                        speed = GetDesiredSpeed();
                        if (speed == 0)
                        {
                            delta = 0;
                            state = AlienStates.StanceStart;
                        }
                        else
                        {
                            alien.Player.Speed = speed;
                        }
                        break;

                    /* Start the walk loop by beginning the clip and entering walk loop */
                    case AlienStates.WalkLoopStart:
                        alien.PlayClip("walkloop").Speed = GetDesiredSpeed();
                        state = AlienStates.WalkLoop;
                        break;

                    case AlienStates.StartEatPie:
                        alien.PlayClip("catcheat");
                        state = AlienStates.EatPie;
                        location.Y = 0;
                        delta = 0;
                        break;

                    case AlienStates.EatPie:
                        if (alien.Player.Time > 2f)
                        {
                            myPie = null;
                        }
                        if (delta > alien.Player.Clip.Duration - alien.Player.Time)
                        {
                            delta = alien.Player.Clip.Duration - alien.Player.Time;

                            myPie = null;
                            // The clip is done after this update
                            state = AlienStates.WalkLoopStart;
                        }

                        break;
                }

                //
                // State update
                //

                alien.Update(delta);

                #region ComputeNewOrientation
                // Enable turning while walking
                float OrientationAdd1 = GetDesiredTurnRate() * (float)delta;

              //  Matrix deltaMatrix = alien.DeltaMatrix;
              //  float OrientationAdd2 = (float)Math.Atan2(deltaMatrix.Backward.X, deltaMatrix.Backward.Z);
                orientation += OrientationAdd1;// +OrientationAdd2;

                #endregion ComputeNewOrientation

                #region ComputeNewLocation
                // We are likely rotated from the angle the model expects to be in
                // Determine that angle.
                Matrix rootMatrix = alien.RootMatrix;
                float actualAngle = (float)Math.Atan2(rootMatrix.Backward.X, rootMatrix.Backward.Z);
                Vector3 newLocation = location + Vector3.TransformNormal(alien.DeltaPosition,
                               Matrix.CreateRotationY(orientation - actualAngle));
                #endregion

                #region LocationCheck
                string region = collisionDetector.TestRegion(newLocation);
                //If region doesn't exist, don't allow you to go in it
                if (region.Equals(String.Empty))
                {
                }
                //Otherwise, it's a valid location
                else
                {
                    //location is in the bounds of the map
                    location = newLocation;
                }
                #endregion

                SetPlayerTransform();

                deltaTotal -= delta;
            } while (deltaTotal > 0);
        }