/// <summary>
        /// Setup this person based on race and gender.
        /// </summary>
        public override void SetPerson(Races race, Genders gender, int personVariant, bool isGuard)
        {
            // Must specify a race
            if (race == Races.None)
            {
                return;
            }

            // Get texture range for this race and gender
            int[] textures = null;

            isUsingGuardTexture = isGuard;

            if (isGuard)
            {
                textures = guardTextures;
            }
            else
            {
                switch (race)
                {
                case Races.Redguard:
                    textures = (gender == Genders.Male) ? maleRedguardTextures : femaleRedguardTextures;
                    break;

                case Races.Nord:
                    textures = (gender == Genders.Male) ? maleNordTextures : femaleNordTextures;
                    break;

                case Races.Breton:
                default:
                    textures = (gender == Genders.Male) ? maleBretonTextures : femaleBretonTextures;
                    break;
                }
            }

            // Setup person rendering
            CacheRecordSizesAndFrames(textures[personVariant]);
            AssignMeshAndMaterial(textures[personVariant]);

            // Setup animation state
            moveAnims        = GetStateAnims(AnimStates.Move);
            idleAnims        = GetStateAnims(AnimStates.Idle);
            stateAnims       = moveAnims;
            animSpeed        = stateAnims[0].FramePerSecond;
            currentAnimState = AnimStates.Move;
            lastOrientation  = -1;
            UpdateOrientation();
        }
Esempio n. 2
0
    public override void Initialize()
    {
        AnimStates.Add(new AnimStateIdle(AnimEngine, Owner));        //E_MyAnimState.E_IDLE
        AnimStates.Add(new AnimStateGoTo(AnimEngine, Owner));        //E_MyAnimState.E_GOTO
        AnimStates.Add(new AnimStateMove(AnimEngine, Owner));        //E_MyAnimState.E_MOVE
        AnimStates.Add(new AnimStateAttackMelee(AnimEngine, Owner)); //E_MyAnimState.E_ATTACK_MELEE
        AnimStates.Add(new AnimStateRoll(AnimEngine, Owner));        //E_MyAnimState.E_ROLL
        AnimStates.Add(new AnimStateUseLever(AnimEngine, Owner));    //use lever
        AnimStates.Add(new AnimStateTeleport(AnimEngine, Owner));    // teleport
        AnimStates.Add(new AnimStateInjury(AnimEngine, Owner));      //E_MyAnimState.E_INJURY
        AnimStates.Add(new AnimStateDeath(AnimEngine, Owner));       //E_MyAnimState._EDEATHM

        DefaultAnimState = AnimStates[(int)E_MyAnimState.E_IDLE];
        base.Initialize();
    }
Esempio n. 3
0
    public override void Initialize()
    {
        AnimStates.Add(new AnimStateIdle(AnimEngine, Owner));        //E_MyAnimState.E_IDLE
        AnimStates.Add(new AnimStateGoTo(AnimEngine, Owner));        //E_MyAnimState.E_GOTO
        AnimStates.Add(new AnimStateCombatMove(AnimEngine, Owner));  //E_MyAnimState.E_GOTO
        AnimStates.Add(new AnimStateRotate(AnimEngine, Owner));      //E_MyAnimState.Rotate
        AnimStates.Add(new AnimStateAttackMelee(AnimEngine, Owner)); //E_MyAnimState.E_ATTACK_MELEE
        AnimStates.Add(new AnimStatePlayAnim(AnimEngine, Owner));    //E_MyAnimState.E_PLAY_ANIM
        AnimStates.Add(new AnimStateInjury(AnimEngine, Owner));      //E_MyAnimState.E_INJURY
        AnimStates.Add(new AnimStateBlocking(AnimEngine, Owner));    //E_MyAnimState.E_BLOCK
        AnimStates.Add(new AnimStateDeath(AnimEngine, Owner));       //E_MyAnimState._E_DEATH

        DefaultAnimState = AnimStates[(int)E_MyAnimState.E_IDLE];
        base.Initialize();
    }
Esempio n. 4
0
        void Update()
        {
            ProcessTestAnimationKeyPresses();

            m_animSpeed = 1.0f;

            AnimState();

            m_curState = AnimStates.Idle;
            m_turnDir  = TurningType.None;

            m_curPos = this.gameObject.transform.position;

            if (!Mathf.Approximately(m_prevPos.x, m_curPos.x) || !Mathf.Approximately(m_prevPos.z, m_curPos.z))
            {
                //Not the most efficient route, but plot a point based on current facing
                Vector3 nextPoint = m_curPos + (this.gameObject.transform.forward);
                //Then get the distance between prev point and "next" point
                float distPrev = Vector3.Distance(m_prevPos, m_curPos);
                float distNext = Vector3.Distance(nextPoint, m_curPos);
                //if (Vector3.Dot(m_curPos - m_prevPos, Vector3.forward) > 0.0f)
                //If we're moving forward then distance between cur and next should always be less than cur and prev
                if (distNext < distPrev)
                {
                    m_curState = AnimStates.MovingBackward;
                }
                else
                {
                    m_curState = AnimStates.MovingForward;
                }
            }
            //{
            //    m_curState = AnimStates.Moving;
            //}

            //If the last grounded height is > 75% of character height, we're falling
            if (m_lastVertHeight - m_curPos.y > (m_controller.height * 0.75f))
            {
                m_curState = AnimStates.Falling;
            }
            //if (!Mathf.Approximately(m_prevPos.y, m_curPos.y))
            //{
            //    m_curState = AnimStates.Falling;
            //}

            m_prevPos = m_curPos;
        }
Esempio n. 5
0
    /// <summary>
    /// Set weapon animation.
    /// </summary>
    public void SetAnimation()
    {
        // detect player status to define animation.
        if (player.grounded)
        {
            if (player.isMoving)
            {
                animStates = AnimStates.Walking;

                if (player.isRunning)
                {
                    animStates = AnimStates.Running;
                }
            }
            else
            {
                animStates = AnimStates.Stopped;
            }
        }
        else
        {
            animStates = AnimStates.Stopped;
        }


        // trigger animation.
        switch (animStates)
        {
        case AnimStates.Stopped:
            _animator.SetFloat("idleSpeed", idleSpeed);
            break;

        case AnimStates.Walking:
            _animator.SetFloat("idleSpeed", idleWalkingSpeed);
            break;

        case AnimStates.Running:
            _animator.SetFloat("idleSpeed", idleRunningSpeed);
            break;

        default:
            _animator.SetFloat("idleSpeed", idleSpeed);
            break;
        }
    }
Esempio n. 6
0
    void FixedUpdate()
    {
        AnimChanger();
        if (!steveAlive)
        {
            state = AnimStates.Dead;
            return;
        }

        if (timer <= 0)
        {
            running = true;
        }
        else
        {
            running = false;
        }

        Stevebounds.center = transform.position;
        float distance = Vector3.Distance(transform.position, goal.transform.position);

        if (distance <= 1f && steveAlive)
        {
            Win();
            running = false;
            return;
        }


        if (!running)
        {
            timer -= Time.deltaTime;
            return;
        }
        else
        {
            state = AnimStates.Running;
            transform.position += Vector3.right * speed * Time.deltaTime;
        }

        if (distance_debug)
        {
            Debug.Log(distance);
        }
    }
Esempio n. 7
0
        protected virtual void ManageMotionInput(float speed)
        {
            body.LinearVelocity = new Vector2(-speed * MotionDataReciever.GetPlayerMotionInput(isPlayerOne).Y, body.LinearVelocity.Y);
            if (body.LinearVelocity.X < 0)
            {
                flipped   = SpriteEffects.FlipHorizontally;
                isFlipped = true;
            }
            else if (body.LinearVelocity.X > 0)
            {
                flipped   = SpriteEffects.None;
                isFlipped = false;
            }

            DetermineButtonState();
            if (currButtonState == LoadCellState.ButtonPressed)
            {
                currState = AnimStates.Flapping;
                DoJump(0, speed);
            }
        }
Esempio n. 8
0
        void Start()
        {
            m_controller    = this.GetComponentInChildren <CharacterController>();
            m_curState      = AnimStates.Idle;
            m_animComponent = this.gameObject.GetComponentInChildren <Animation>();

            m_isDead    = false;
            m_isSitting = false;

            for (int i = 0; i < (int)AnimationType.DEFAULT; i++)
            {
                m_animComponent.AddClip(characterAnimations[i], ((AnimationType)i).ToString());
            }

            m_animComponent.Play(characterAnimations[(int)AnimationType.Idle].name);

            m_animComponent.wrapMode = WrapMode.Loop;

            m_attackType = AnimAttackType.None;
            m_turnDir    = TurningType.None;
        }
 // Update is called once per frame
 void Update()
 {
     if (Time.time - lastChangeTime > 10f)
     {
         if (currState == AnimStates.Bend)
         {
             anim.SetTrigger("Jitter");
             currState = AnimStates.Jitter;
         }
         else if (currState == AnimStates.Look)
         {
             anim.SetTrigger("Bend");
             currState = AnimStates.Bend;
         }
         else if (currState == AnimStates.Jitter)
         {
             anim.SetTrigger("Look");
             currState = AnimStates.Look;
         }
         lastChangeTime = Time.time;
     }
 }
Esempio n. 10
0
    public override void Initialize()
    {
        /*
         * 初始化属于可见物体的状态机
         */
        AnimStates.Add(AnimActionFactory.E_Type.Idle, new AnimStateIdle(AnimEngine, Owner));
        AnimStates.Add(AnimActionFactory.E_Type.PlayAnim, new AnimStatePlayAnim(AnimEngine, Owner));
        AnimStates.Add(AnimActionFactory.E_Type.Move, new AnimStateMove(AnimEngine, Owner));
        AnimStates.Add(AnimActionFactory.E_Type.UseSkill, new AnimStateUseSkill(AnimEngine, Owner));
        AnimStates.Add(AnimActionFactory.E_Type.Death, new AnimStateDeath(AnimEngine, Owner));


        //设置默认的动画状态
        DefaultAnimState = AnimStates[AnimActionFactory.E_Type.Idle];

        if (AnimEngine == null)
        {
            return;
        }

        AnimEngine.eventListener += HandleMecAnimEvent;
    }
 public void ShipAnim()
 {
     //this would only work for horizontal animation
     //if there is input from the joystick
     if (moveJoystick.inputDirection != Vector3.zero)
     {
         //if the joystick/ship movement is towards the right direction, x++
         if (moveJoystick.inputDirection.x > 0.0f)
         {
             //start the timer for the right animation frames
             rightTimer += Time.deltaTime;
             //reset the left animation frames timer
             leftTimer = 0.0f;
         }
         else
         {
             //the left direction, x--
             if (moveJoystick.inputDirection.x < 0.0f)
             {
                 //reset the timer for the right anim frames
                 rightTimer = 0.0f;
                 //start the timer for the left anim frames
                 leftTimer += Time.deltaTime;
             }
         }
     }
     else
     {
         //if there is movement from the joystick, reset all timers
         leftTimer  = 0.0f;
         rightTimer = 0.0f;
         //and the current sprite of the ship should be idle
         currentState = AnimStates.Idle;
     }
     //determine the state in order to determine the sprite
     DetermineState();
     ChangeSprite();
 }
 void SetIdle(bool idle)
 {
     if (idle)
     {
         // Switch animation state to idle
         currentAnimState = AnimStates.Idle;
         stateAnims       = idleAnims;
         currentFrame     = 0;
         lastOrientation  = -1;
         animTimer        = 1;
         animSpeed        = stateAnims[0].FramePerSecond;
     }
     else
     {
         // Switch animation state to move
         currentAnimState = AnimStates.Move;
         stateAnims       = moveAnims;
         currentFrame     = 0;
         lastOrientation  = -1;
         animTimer        = 1;
         animSpeed        = stateAnims[0].FramePerSecond;
     }
 }
 public void DetermineState()
 {
     if (rightTimer > 0.0f)
     {
         //based on how much time has passed, determine with frame to use
         if (rightTimer > slightTimer && rightTimer < farTimer)
         {
             currentState = AnimStates.SlightRight;
         }
         else if (rightTimer > farTimer)
         {
             currentState = AnimStates.FarRight;
         }
     }
     else
     {
         if (leftTimer > 0.0f)
         {
             if (leftTimer > slightTimer && leftTimer < farTimer)
             {
                 currentState = AnimStates.SlightLeft;
             }
             else if (leftTimer > farTimer)
             {
                 currentState = AnimStates.FarLeft;
             }
         }
         else
         {
             //keep using the idle frame until the timers reach a point where the sprite can change
             if (currentState != AnimStates.Idle)
             {
                 currentState = AnimStates.Idle;
             }
         }
     }
 }
Esempio n. 14
0
        public void CharTurning(bool clockwise)
        {
            if (m_isCrouching)
            {
                return;
            }

            // zer0sum: dont play turn anim if we're running...
            // if (Input.GetKey(KeyCode.W) || (Input.GetMouseButton(0) && Input.GetMouseButtonDown(1)))
            if (m_curState == AnimStates.MovingForward || m_curState == AnimStates.MovingSideWays || m_curState == AnimStates.MovingBackward)
            {
                return;
            }

            m_curState = AnimStates.Turning;
            if (clockwise)
            {
                m_turnDir = TurningType.ClockWise;
            }
            else
            {
                m_turnDir = TurningType.CClockWise;
            }
        }
Esempio n. 15
0
    void UpdateAnimation()
    {
        switch (sanim) {
        case AnimStates.TO_SHOW:
            atime+=Time.deltaTime;
            if(atime>fedinTime){
                setScale(startScale);
                sanim=AnimStates.SHOW;
            }
            else{

                float time=(atime/fedinTime);
                Vector3 nextscale;
                nextscale.x=time*startScale.x;
                nextscale.y=time*startScale.y;
                nextscale.z=time*startScale.z;
                setScale(nextscale);
            }
            //enable collision and grf
            collider.enabled=renderer.enabled=true;
            //Debug.Log ("to show color:" + color);
            break;
        case AnimStates.SHOW:
            atime=0.0f;
            break;
        case AnimStates.TO_HIDE:
            atime+=Time.deltaTime;
            if(atime>fedoutTime){
                setScale(Vector3.zero);
                sanim=AnimStates.HIDE;
            }
            else{
                float time=(1.0f-(atime/fedoutTime));
                Vector3 nextscale;
                nextscale.x=time*startScale.x;
                nextscale.y=time*startScale.y;
                nextscale.z=time*startScale.z;
                setScale(nextscale);
            }
            //Debug.Log ("to hide color:" + color);
            break;
        case AnimStates.HIDE:
            //enable collision and grf
            atime=0.0f;
            collider.enabled=renderer.enabled=false;
            break;
        default: break;
        };
    }
Esempio n. 16
0
 void toShow()
 {
     atime=0.0f;
     sanim = AnimStates.TO_SHOW;
 }
Esempio n. 17
0
 void toHide()
 {
     atime=0.0f;
     sanim = AnimStates.TO_HIDE;
 }
Esempio n. 18
0
 void UpdateAnimation()
 {
     Color color;
     switch (sanim) {
     case AnimStates.TO_SHOW:
         atime+=Time.deltaTime;
         color=getColor();
         color.a=(atime/fedinTime);
         if(atime>fedinTime){
             color.a=1.0f;
             sanim=AnimStates.SHOW;
         }
         setColor(color);
         //enable collision and grf
         collider.enabled=renderer.enabled=true;
         //Debug.Log ("to show color:" + color);
         break;
     case AnimStates.SHOW:
         atime=0.0f;
     break;
     case AnimStates.TO_HIDE:
         atime+=Time.deltaTime;
         color=getColor();
         color.a=1.0f-(atime/fedoutTime);
         if(atime>fedoutTime){
             color.a=0.0f;
             sanim=AnimStates.HIDE;
         }
         setColor(color);
         //Debug.Log ("to hide color:" + color);
         break;
     case AnimStates.HIDE:
         //enable collision and grf
         atime=0.0f;
         collider.enabled=renderer.enabled=false;
         break;
     default: break;
     };
 }
Esempio n. 19
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.E))
        {
            if (Physics.Raycast(transform.position, transform.forward, out hit, rayDistance))
            {
                if (hit.collider)
                {
                    if (hit.collider.gameObject.tag == "GenericDoor")
                    {
                        doorHit = 1;    // Normal door
                    }

                    else if (hit.collider.gameObject.tag == "LockedDoor")
                    {
                        doorHit = 2;    // Locked door
                    }

                    if (doorHit > 0)
                    {
                        bool        locked      = false;
                        PlayerLogic playerLogic = player.GetComponent <PlayerLogic>();
                        door = hit.collider.gameObject;

                        if (doorHit == 2)
                        {
                            LockState lockState = door.GetComponent <LockState>();
                            string    key       = lockState.getKeyName();

                            if (playerLogic.HasItem(key))
                            {
                                lockState.unlock();
                            }

                            locked = lockState.getState();
                        }

                        if (locked == false)
                        {
                            door.GetComponent <AudioSource>().Play();
                            doorState = door.GetComponent <AnimStates>();
                            Animation anim = door.GetComponent <Animation>();
                            anim.Play(doorState.states[doorState.getState()]);
                            doorState.incState();

                            if (doorHit == 2)
                            {
                                door.tag = "GenericDoor";
                            }
                        }
                        else
                        {
                            _AudioSource.Stop();
                            _AudioSource.clip = clipLocked;
                            _AudioSource.Play();
                        }

                        doorHit = 0;
                    }
                }
            }
        }
    }
Esempio n. 20
0
        //OnBeginState
        // if -> state01
        // else -> state02



        // Update is called once per frame
        void Update()
        {
            if (health == 0)
            {
                Destroy(spawner);
            }

            base.Update();

            if (turretLeft.isShooting)
            {
                timer++;
            }

            if (health < initialHealth / 2f)
            {
                SecondPhase  = true;
                TPThreashold = 1;
            }

            if (timer >= TPThreashold)
            {
                StartCoroutine(StartTeleport());
                timer = 0;
            }

            if (ShouldTP)
            {
                turretLeft.shouldShoot = turretRight.shouldShoot = false;
                ShouldMove             = false;
                ShouldShoot            = false;

                if (animStates == AnimStates.None)
                {
                    animStates = AnimStates.Smalling;
                }

                if (transform.localScale.x <= 0.1f && !TP)
                {
                    animStates = AnimStates.Teleport;
                }

                if (animStates == AnimStates.Smalling)
                {
                    transform.localScale = Vector3.Lerp(transform.localScale, Vector3.zero, Time.deltaTime * animationTime);
                }

                if (animStates == AnimStates.Teleport)
                {
                    if (SecondPhase)
                    {
                        TPOffset = new Vector3(/*Random.Range(0.05f, 0.1f)*/ 0f, Random.Range(-0.3f, 0.3f), 0f);

                        SideChange++;
                        if (SideChange >= Random.Range(0, 3))
                        {
                            side = -side;
                            transform.rotation = new Quaternion(transform.rotation.x, transform.rotation.y, -transform.rotation.z, transform.rotation.w);
                            SideChange         = 0;
                        }
                    }
                    else
                    {
                        side = -side;
                        transform.rotation = new Quaternion(transform.rotation.x, transform.rotation.y, -transform.rotation.z, transform.rotation.w);
                        TPOffset           = Vector3.zero;
                    }

                    if (side == 1f)
                    {
                        transform.position = Camera.main.ViewportToWorldPoint(new Vector3(1f, 0.5f, 0) + TPOffset) + Vector3.forward * 10f;
                        spawner.invert     = -1f;
                    }
                    else if (side == -1f)
                    {
                        transform.position = Camera.main.ViewportToWorldPoint(new Vector3(0f, 0.5f, 0) + TPOffset) + Vector3.forward * 10f;
                        spawner.invert     = 1f;
                    }
                    startPos = transform.position + transform.up * 2;

                    if (height)
                    {
                        currGoal = startPos + new Vector3(Random.Range(-2f, -1f) * side, Random.Range(1.5f, 2f), 0f);
                        height   = false;
                    }
                    else
                    {
                        currGoal = startPos + new Vector3(Random.Range(-2f, -1f) * side, Random.Range(-2f, -1.5f), 0f);
                        height   = true;
                    }

                    TP         = true;
                    animStates = AnimStates.Bigenning;
                }

                if (animStates == AnimStates.Bigenning)
                {
                    transform.localScale = Vector3.Lerp(transform.localScale, Vector3.one, Time.deltaTime * animationTime);

                    if (transform.localScale.x >= 0.9f)
                    {
                        animStates = AnimStates.None;
                        StartCoroutine(ResetTeleport());
                        TP    = false;
                        timer = 0;
                    }
                }
            }

            //Vector3 rand;
            ////if (SPHeight)
            ////{
            ////   rand = new Vector3(Random.Range(-1f, 0f) * side, Random.Range(0f, 1f), 0f);
            ////    SPHeight = false;
            ////}
            ////else
            ////{
            ////    rand = new Vector3(Random.Range(-1f, 0f) * side, Random.Range(-1f, 0f), 0f);
            ////    SPHeight = true;
            ////}



            if (ShouldShoot && Vector3.Distance(transform.position, currGoal) < 0.8f /*&& (turretLeft.isShooting || turretRight.isShooting)*/)
            {
                //Maybe in the direction of player when theres no snipers
                if (height)
                {
                    currGoal = startPos + new Vector3(Random.Range(-1.5f, -1f) * side, Random.Range(1.5f, 1f), 0f);
                    height   = false;
                }
                else
                {
                    currGoal = startPos + new Vector3(Random.Range(-1.5f, -1f) * side, Random.Range(-3f, -1f), 0f);
                    height   = true;
                }
                turretLeft.shouldShoot = turretRight.shouldShoot = true;
            }

            if (ShouldMove)
            {
                transform.position = Vector3.Lerp(transform.position, currGoal, Time.deltaTime);
            }



            //rand = new Vector3(/*Random.Range(0f, 0.8f) * SPSide*/ 0f, Random.Range(0f, 0.8f) * SPHeight, 0f);
            //SPSide *= -1f;
            //SPHeight *= -1f;

            ////if (SecondPhase)
            //if(Vector3.Distance(transform.position, transform.position + rand) <= 1f)
            //{
            //    transform.position = transform.position + rand;
            //}
        }
Esempio n. 21
0
        public void CharTurning(bool clockwise)
        {
            if (m_isCrouching)
                return;

               // zer0sum: dont play turn anim if we're running...
               // if (Input.GetKey(KeyCode.W) || (Input.GetMouseButton(0) && Input.GetMouseButtonDown(1)))
            if (m_curState == AnimStates.MovingForward || m_curState == AnimStates.MovingSideWays || m_curState == AnimStates.MovingBackward)
                return;

            m_curState = AnimStates.Turning;
            if (clockwise)
            {
                m_turnDir = TurningType.ClockWise;
            }
            else
            {
                m_turnDir = TurningType.CClockWise;
            }
        }
Esempio n. 22
0
    void Update()
    {
        bool second_controller = false;

        if (!playerIndexSet || !prevState.IsConnected)
        {
            for (int i = 0; i < 4; ++i)
            {
                PlayerIndex  testPlayerIndex = (PlayerIndex)i;
                GamePadState testState       = GamePad.GetState(testPlayerIndex);
                if (testState.IsConnected)
                {
                    Debug.Log(string.Format("GamePad found {0}", testPlayerIndex));
                    playerIndex    = testPlayerIndex;
                    playerIndexSet = true;

                    if (second_controller)
                    {
                        break;
                    }

                    second_controller = true;
                }
            }
        }


        prevState = state;
        state     = GamePad.GetState(playerIndex);

        if (sceneManaging.do_actions)
        {
            if (actual_shoot_time >= shoot_time)
            {
                if (state.ThumbSticks.Left.Y > 0.1f || Input.GetKey(up_input))
                {
                    rigidbody2D.AddForce(Vector2.up * speed * Time.deltaTime);
                    // pos.y += speed * Time.deltaTime;
                    shadow_child.GetComponent <ShadowBehaviour>().SetPlayerInput(ShadowBehaviour.PlayerInput.UP);
                    animator.SetInteger("State", 0);
                    lastState = AnimStates.UP;

                    if (animator.GetBool("Idle"))
                    {
                        animator.SetBool("Idle", false);
                    }
                }
                else if (state.ThumbSticks.Left.Y < -0.1f || Input.GetKey(down_input))
                {
                    rigidbody2D.AddForce(Vector2.down * speed * Time.deltaTime);
                    //pos.y -= speed * Time.deltaTime;
                    shadow_child.GetComponent <ShadowBehaviour>().SetPlayerInput(ShadowBehaviour.PlayerInput.DOWN);
                    animator.SetInteger("State", 1);
                    lastState = AnimStates.DOWN;

                    if (animator.GetBool("Idle"))
                    {
                        animator.SetBool("Idle", false);
                    }
                }
                else if (state.ThumbSticks.Left.X > 0.1f || Input.GetKey(right_input))
                {
                    rigidbody2D.AddForce(Vector2.right * speed * Time.deltaTime);
                    //pos.x += speed * Time.deltaTime;
                    shadow_child.GetComponent <ShadowBehaviour>().SetPlayerInput(ShadowBehaviour.PlayerInput.RIGHT);
                    animator.SetInteger("State", 2);
                    lastState = AnimStates.RIGHT;

                    if (animator.GetBool("Idle"))
                    {
                        animator.SetBool("Idle", false);
                    }
                    //sprite.flipX = false;
                }
                else if (state.ThumbSticks.Left.X < -0.1f || Input.GetKey(left_input))
                {
                    rigidbody2D.AddForce(Vector2.left * speed * Time.deltaTime);
                    //pos.x -= speed * Time.deltaTime;
                    shadow_child.GetComponent <ShadowBehaviour>().SetPlayerInput(ShadowBehaviour.PlayerInput.LEFT);
                    animator.SetInteger("State", 3);
                    lastState = AnimStates.LEFT;

                    if (animator.GetBool("Idle"))
                    {
                        animator.SetBool("Idle", false);
                    }
                    //sprite.flipX = true;
                }
                else
                {
                    if (!animator.GetBool("Idle"))
                    {
                        animator.SetBool("Idle", true);
                    }
                    animator.SetInteger("State", -1);
                    shadow_child.GetComponent <ShadowBehaviour>().SetPlayerInput(ShadowBehaviour.PlayerInput.WAIT);
                }
            }
            else
            {
                if (!animator.GetBool("Idle"))
                {
                    animator.SetBool("Idle", true);
                }
                animator.SetInteger("State", -1);
                shadow_child.GetComponent <ShadowBehaviour>().SetPlayerInput(ShadowBehaviour.PlayerInput.WAIT);
                actual_shoot_time += Time.deltaTime;
            }


            if (actual_cooldown >= cooldown_shoot)
            {
                if (state.Buttons.LeftShoulder == ButtonState.Pressed || Input.GetKey(shoot_input))
                {
                    actual_cooldown   = 0.0f;
                    actual_shoot_time = 0.0f;
                    shadow_child.GetComponent <ShadowBehaviour>().SetPlayerInput(ShadowBehaviour.PlayerInput.SHOOT);
                    NotReallyFire();
                }
            }
            else
            {
                actual_cooldown += Time.deltaTime;
            }
        }
    }
Esempio n. 23
0
        void Start()
        {
            m_controller = this.GetComponentInChildren<CharacterController>();
            m_curState = AnimStates.Idle;
            m_animComponent = this.gameObject.GetComponentInChildren<Animation>();

            m_isDead = false;
            m_isSitting = false;

            for (int i = 0; i < (int)AnimationType.DEFAULT; i++)
            {
                m_animComponent.AddClip(characterAnimations[i], ((AnimationType)i).ToString());
            }

            m_animComponent.Play(characterAnimations[(int)AnimationType.Idle].name);

            m_animComponent.wrapMode = WrapMode.Loop;

            m_attackType = AnimAttackType.None;
            m_turnDir = TurningType.None;
        }
Esempio n. 24
0
        void Update()
        {
            ProcessTestAnimationKeyPresses();

            m_animSpeed = 1.0f;

            AnimState();

            m_curState = AnimStates.Idle;
            m_turnDir = TurningType.None;

            m_curPos = this.gameObject.transform.position;

            if (!Mathf.Approximately(m_prevPos.x, m_curPos.x) || !Mathf.Approximately(m_prevPos.z, m_curPos.z))
            {
                //Not the most efficient route, but plot a point based on current facing
                Vector3 nextPoint = m_curPos + (this.gameObject.transform.forward);
                //Then get the distance between prev point and "next" point
                float distPrev = Vector3.Distance(m_prevPos, m_curPos);
                float distNext = Vector3.Distance(nextPoint, m_curPos);
                //if (Vector3.Dot(m_curPos - m_prevPos, Vector3.forward) > 0.0f)
                //If we're moving forward then distance between cur and next should always be less than cur and prev
                if(distNext < distPrev)
                {
                    m_curState = AnimStates.MovingBackward;
                }
                else
                {
                    m_curState = AnimStates.MovingForward;
                }
            }
            //{
            //    m_curState = AnimStates.Moving;
            //}

            //If the last grounded height is > 75% of character height, we're falling
            if (m_lastVertHeight - m_curPos.y > (m_controller.height * 0.75f))
            {
                m_curState = AnimStates.Falling;
            }
            //if (!Mathf.Approximately(m_prevPos.y, m_curPos.y))
            //{
            //    m_curState = AnimStates.Falling;
            //}

            m_prevPos = m_curPos;
        }
Esempio n. 25
0
 protected void Jump()
 {
     currState = AnimStates.Flapping;
     DoJump(0, jumpSpeed);
 }
Esempio n. 26
0
 public void SetStateToStun()
 {
     current = AnimStates.stun;
 }
Esempio n. 27
0
 public void SetStateToIdle()
 {
     current = AnimStates.idle;
 }