public void SetState(PlayerAnimationState state)
    {
        switch (state)
        {
        case PlayerAnimationState.Idle:
            _animator.SetBool(IsCastingSkill, false);
            _animator.SetBool(IsWalking, false);
            _animator.SetBool(IsIdle, true);
            break;

        case PlayerAnimationState.Walking:
            _animator.SetBool(IsIdle, false);
            _animator.SetBool(IsCastingSkill, false);
            _animator.SetBool(IsWalking, true);
            break;

        case PlayerAnimationState.CastingSkill:
            _animator.SetBool(IsIdle, false);
            _animator.SetBool(IsWalking, false);
            _animator.SetBool(IsCastingSkill, true);
            break;

        case PlayerAnimationState.Dead:
            _animator.SetBool(IsIdle, false);
            _animator.SetBool(IsWalking, false);
            _animator.SetBool(IsDead, true);
            break;
        }
    }
Exemple #2
0
        protected override void Update(TimeSpan gameTime)
        {
            HandleKeys(gameTime);

            if (jumpRemaining > 0)
            {
                jumpRemaining -= gameTime.Milliseconds;
            }

            if (protectionRemaining > 0)
            {
                protectionRemaining -= gameTime.Milliseconds;
            }

            if (animationRemaining > 0)
            {
                animationRemaining -= gameTime.Milliseconds;
            }
            else if (animationRemaining <= 0)
            {
                if (playerAnimState == PlayerAnimationState.Growing)
                {
                    playerAnimState            = PlayerAnimationState.BigWalking;
                    Animation.CurrentAnimation = Game.PLAYER_BIG_WALKING;
                    Animation.Play(true);
                }
                else if (playerAnimState == PlayerAnimationState.Shrinking)
                {
                    playerAnimState            = PlayerAnimationState.SmallWalking;
                    Animation.CurrentAnimation = Game.PLAYER_SMALL_WALKING;
                    Animation.Play(true);
                }
            }
        }
Exemple #3
0
 /// <summary>
 /// Player attempts to gather a plant
 /// </summary>
 /// <param name="gatheringDirection">The direction the gathering animation should be played</param>
 private void Gathering(PlayerAnimationState gatheringDirection, GameTime gameTime)
 {
     playerAnimationState = gatheringDirection;
     gatherAnimTimer     += gameTime.ElapsedGameTime.TotalSeconds;
     if (gatherAnimTimer >= GATHER_ANIMATION_TIMER_INTERVAL)
     {
         //If we are colliding with a plant
         if (PlantManager.GetPlantCollisions(collider) != null)
         {
             if (itemsInInventory.Count < MAX_ITEMS_IN_INVENTORY)
             {
                 InventoryItem item = PlantManager.GetPlantCollisions(collider).Gather();
                 Game.Services.GetService <GameplayScene>().SceneComponents.Add(item);
                 Game.Components.Add(item);
                 itemsInInventory.Add(item);
                 PlayGatherSound();
             }
         }
         //else If we are colliding with a collection box
         else if (collider.Intersects(Game.Services.GetService <GoodCollectionBox>().GetCollider()))
         {
             InsertItemsFromHandToBox(Game.Services.GetService <GoodCollectionBox>());
         }
         else if (collider.Intersects(Game.Services.GetService <BadCollectionBox>().GetCollider()))
         {
             InsertItemsFromHandToBox(Game.Services.GetService <BadCollectionBox>());
         }
     }
 }
Exemple #4
0
        void ChangeState(PlayerAnimationState state)
        {
            if (playerState == state)
            {
                return;
            }

            OnExitState(state);

            switch (state)
            {
            case PlayerAnimationState.Idle:
                _Anim.Play("Idle");
                break;

            case PlayerAnimationState.Run:
                _Anim.Play("Run");
                break;

            case PlayerAnimationState.Jump:
                _Anim.Play("JumpStart");
                break;

            case PlayerAnimationState.Attack:
                _Anim.Play("Fire");
                break;

            case PlayerAnimationState.Death:
                _Anim.Play("Death");
                break;
            }

            playerState = state;
        }
Exemple #5
0
        private void OnPlayerCollision(object sender, Physic2DCollisionEventArgs args)
        {
            RigidBody2D other = args.Body2DA == RigidBody ? args.Body2DB : args.Body2DA;

            if (other.Owner.Tag == Game.TAG_EYE)
            {
                EyeController eye = other.Owner.FindComponent <EyeController>();
                if (eye.IsHot && !IsProtected)
                {
                    Die();
                }
                else if (eye.IsCool && !HasEye())
                {
                    AttachEye(other.Owner);
                    Animation.CurrentAnimation = Game.PLAYER_SHRINKING;
                    Animation.Play();
                    animationRemaining = AnimationTransition;
                    playerAnimState    = PlayerAnimationState.Shrinking;
                }
            }
            else if (args.PointA.HasValue && args.PointB.HasValue &&
                     args.PointA.Value.Y == args.PointB.Value.Y &&
                     args.PointA.Value.X != args.PointB.Value.X)
            {
                ;//this.soundManager.PlaySound(SoundType.Contact);
                collidingBodies.Add(other);
            }
        }
 void Fall()
 {
     velocity.y           = 0;
     playerAnimationState = PlayerAnimationState.jumping;
     grounded             = false;
     bounce = false;
 }
        public void TriggerAnimation(PlayerAnimationState i_eState)
        {
            switch (i_eState)
            {
            case PlayerAnimationState.Idling:
                m_animator.SetTrigger(m_hashIdleTrigger);
                break;

            case PlayerAnimationState.Moving:
                RotateModel(Player.Instance.GetMoveDirection());
                m_animator.SetTrigger(m_hashMoveTrigger);
                break;

            case PlayerAnimationState.Death:
                m_animator.SetTrigger(m_hashDeadTrigger);
                break;

            case PlayerAnimationState.Reviving:
                m_animator.SetTrigger(m_hashReviveTrigger);
                break;

            case PlayerAnimationState.Respawning:
                m_animator.SetTrigger(m_hashFallTrigger);
                break;

            default:
                break;
            }
        }
Exemple #8
0
 void ProcessCurrentAnimationStatus()
 {
     if (M_Controller_Mark2.MARK2_CHARCONTROLLER.isGrounded)
     {
         if (CurrentMark2AnimeStatee != PlayerAnimationState.FALL &&
             CurrentMark2AnimeStatee != PlayerAnimationState.ATTACK &&
             CurrentMark2AnimeStatee != PlayerAnimationState.LANDING &&
             CurrentMark2AnimeStatee != PlayerAnimationState.TURNING &&
             CurrentMark2AnimeStatee != PlayerAnimationState.STAND_BY)
         {
             if (M_Motor_Mark2.INSTANCE.MoveVector.x != 0)
             {
                 CurrentMark2AnimeStatee = PlayerAnimationState.RUN;
             }
             else
             {
                 CurrentMark2AnimeStatee = PlayerAnimationState.IDLE;
             }
         }
     }
     else
     {
         CurrentMark2AnimeStatee = PlayerAnimationState.FALL;
     }
 }
Exemple #9
0
 // Use this for initialization
 void Start()
 {
     //Set private Animation component to the Animation component attached to this item
     playerAnim      = GetComponent <Animator>();
     pas             = PlayerAnimationState.idle;
     comboTimeWindow = 1f;
 }
Exemple #10
0
 private void AddToDictionaries(PlayerAnimationState state, int index, AudioClip audioToPlay, bool loopAudio, int priority = 10)
 {
     if (DictionaryAnimationToIndex == null)
     {
         DictionaryAnimationToIndex = new Dictionary <PlayerAnimationState, int>();
     }
     if (DictionaryAnimationToPriority == null)
     {
         DictionaryAnimationToPriority = new Dictionary <PlayerAnimationState, int>();
     }
     if (DictionaryAnimationToSfx == null)
     {
         DictionaryAnimationToSfx = new Dictionary <PlayerAnimationState, AudioClip>();
     }
     if (DictionaryAnimationToLoopSfx == null)
     {
         DictionaryAnimationToLoopSfx = new Dictionary <PlayerAnimationState, bool>();
     }
     if (!DictionaryAnimationToIndex.ContainsKey(state))
     {
         DictionaryAnimationToIndex.Add(state, index);
     }
     if (!DictionaryAnimationToPriority.ContainsKey(state))
     {
         DictionaryAnimationToPriority.Add(state, priority);
     }
     if (!DictionaryAnimationToSfx.ContainsKey(state))
     {
         DictionaryAnimationToSfx.Add(state, audioToPlay);
     }
     if (!DictionaryAnimationToLoopSfx.ContainsKey(state))
     {
         DictionaryAnimationToLoopSfx.Add(state, loopAudio);
     }
 }
        protected override void OnUpdate()
        {
            EntityCommandBuffer    commandBuffer = PostUpdateCommands;
            List <EntryPlayerAnim> listAnim      = GameManager.entitiesPlayerAnim;

            for (int i = 0; i < parentData.Length; i++)
            {
                Entity        animEntity = parentData.AnimationIdleEntities[i];
                Parent        parent     = parentData.Parent[i];
                Player        player     = parentData.Player[i];
                FaceDirection faceDir    = parentData.FaceDirection[i];

                commandBuffer.RemoveComponent <AnimationPlayerAttack1>(animEntity);

                //SET LIST
                // int dirIndex = faceDir.dirIndex;
                // float3 faceDirValue = faceDir.Value;
                PlayerAnimationState state = PlayerAnimationState.ATTACK_1;
                // int endAnimToggle = listAnim[parent.AnimIndex].EndAnimationToggle;

                EntryPlayerAnim entryPlayerAnim = listAnim[parent.AnimIndex];
                entryPlayerAnim.State = state;
                entryPlayerAnim.StartAnimationToggle = 21;

                // listAnim[parent.AnimIndex] = new EntryPlayerAnim(dirIndex, faceDirValue, state, 21, endAnimToggle);
                listAnim[parent.AnimIndex] = entryPlayerAnim;

                //SET TO PLAYER (PARENT)
                player.State         = state;
                parentData.Player[i] = player;
            }
        }
Exemple #12
0
    //метод, который обновляет позицию Марио в зависимости от ввода с клавиатуры
    void UpdatePosition()
    {
        Vector3 pos   = transform.localPosition;
        Vector3 scale = transform.localScale;

        if (walk)
        {
            if (walk_left)
            {
                pos.x  -= velocity.x * Time.deltaTime;
                scale.x = -1;
            }

            if (walk_right)
            {
                pos.x  += velocity.x * Time.deltaTime;
                scale.x = 1;
            }

            pos = CheckWallRays(pos, scale.x);
        }

        if (jump && playerAnimationState != PlayerAnimationState.jumping)
        {
            playerAnimationState = PlayerAnimationState.jumping;
            velocity             = new Vector2(velocity.x, jumpHeight);
            grounded             = false;
        }

        if (playerAnimationState == PlayerAnimationState.jumping)
        {
            pos.y      += velocity.y * Time.deltaTime;
            velocity.y -= gravity * Time.deltaTime;
        }

        if (bounce && playerAnimationState != PlayerAnimationState.bouncing)
        {
            playerAnimationState = PlayerAnimationState.bouncing;
            velocity             = new Vector2(velocity.x, bounceHeight);
        }

        if (playerAnimationState == PlayerAnimationState.bouncing)
        {
            pos.y      += velocity.y * Time.deltaTime;
            velocity.y -= gravity * Time.deltaTime;
        }

        if (velocity.y <= 0)
        {
            pos = CheckGroundRays(pos);
        }

        if (velocity.y >= 0)
        {
            pos = CheckCeilingRays(pos);
        }

        transform.localPosition = pos;
        transform.localScale    = scale;
    }
 //function to handle the jumping loop animation
 public void _on_Sprite_animation_finished()
 {
     if (_state == PlayerState.Jumping && _animationState == PlayerAnimationState.JumpStart)
     {
         _animationState = PlayerAnimationState.JumpLoop;
     }
 }
 public EntryPlayerAnim(int dirIndex, float3 faceDirValue, PlayerAnimationState state, int startAnimToggle, int endAnimToggle)
 {
     DirIndex             = dirIndex;
     FaceDirValue         = faceDirValue;
     State                = state;
     StartAnimationToggle = startAnimToggle;
     EndAnimationToggle   = endAnimToggle;
 }
Exemple #15
0
 public void SetAnimationState(PlayerAnimationState newState)
 {
     if (PriorityAnimation(newState))
     {
         animator.SetInteger("State", DictionaryAnimationToIndex[newState]);
         PlayCorrespondingSfx(newState);
     }
 }
Exemple #16
0
 public void UpdateAnimationState(PlayerAnimationState animationState)
 {
     if (this.animationState != animationState)
     {
         this.animationState = animationState;
         animator.SetTrigger(animationState.ToTrigger());
     }
 }
Exemple #17
0
 public void EndCombat()
 {
     if (!EnsureAnimator())
     {
         return;
     }
     animationState = PlayerAnimationState.Idle;
     SetBool("Attacking", false);
 }
Exemple #18
0
    void AttackUpdate()
    {
        input = Vector2.zero;

        // ---

        if (canEndAttack || canGoToNextAttack)
        {
            if (Input.GetKeyDown(KeyCode.Z) || queueAttack)
            {
                animationState    = animationState == PlayerAnimationState.Attack ? PlayerAnimationState.Attack2 : PlayerAnimationState.Attack;
                canEndAttack      = false;
                canGoToNextAttack = false;
                queueAttack       = false;
            }
            else if (canEndAttack)
            {
                input.x = Input.GetAxisRaw("Horizontal");
                input.y = Input.GetAxisRaw("Vertical");
                input.Normalize();

                if (!isGrounded)
                {
                    input = Vector2.zero;
                }

                if (input != Vector2.zero)
                {
                    ChangeState(PlayerState.Normal);
                }
            }
        }
        else
        {
            if (Input.GetKeyDown(KeyCode.Z))
            {
                queueAttack = true;
            }
        }

        // ---

        Vector3 movementX = Camera.main.transform.right * input.x;
        Vector3 movementZ = Camera.main.transform.forward * input.y;
        Vector3 movement  = movementX + movementZ;

        if (movement != Vector3.zero)
        {
            transform.rotation = Quaternion.LookRotation(new Vector3(movement.x, 0, movement.z));
        }

        rigidbody.velocity = new Vector3(
            rigidbody.velocity.x.MoveOverTime(movement.x * Speed, Acceleration),
            rigidbody.velocity.y - (Gravity * Time.deltaTime),
            rigidbody.velocity.z.MoveOverTime(movement.z * Speed, Acceleration)
            );
    }
Exemple #19
0
 private void OnExitState(PlayerAnimationState state)
 {
     switch (state)
     {
     case PlayerAnimationState.Run:
         currentMoveSpeed = 0;
         break;
     }
 }
Exemple #20
0
 public void EndFarming()
 {
     if (!EnsureAnimator())
     {
         return;
     }
     animationState = PlayerAnimationState.Idle;
     SetBool("Farming", false);
 }
    //On death screen
    public void _on_Light_extinguished()
    {
        _state          = PlayerState.Dead;
        _animationState = PlayerAnimationState.Death;
        UpdatePlayerState();
        UpdateAnimation();

        AddChild(_gameOverScreen.Instance());
    }
 public void Revive()
 {
     if (!EnsureAnimator())
     {
         return;
     }
     animationState = PlayerAnimationState.Idle;
     animator.SetBool("Dead", false);
 }
 public void SetCaptainState(bool isCaptain)
 {
     if (!EnsureAnimator())
     {
         return;
     }
     animationState = PlayerAnimationState.Captain;
     animator.SetBool("Captain", isCaptain);
 }
 public void EndCooking()
 {
     if (!EnsureAnimator())
     {
         return;
     }
     animationState = PlayerAnimationState.Idle;
     animator.SetBool("Cooking", false);
 }
 public void Death()
 {
     if (!EnsureAnimator())
     {
         return;
     }
     animationState = PlayerAnimationState.Dead;
     animator.SetBool("Dead", true);
 }
 public void Fish()
 {
     if (!EnsureAnimator())
     {
         return;
     }
     animationState = PlayerAnimationState.Fishing;
     animator.SetBool("Fishing", true);
 }
 public void Craft()
 {
     if (!EnsureAnimator())
     {
         return;
     }
     animationState = PlayerAnimationState.Crafting;
     animator.SetBool("Crafting", true);
 }
 public void Mine()
 {
     if (!EnsureAnimator())
     {
         return;
     }
     animationState = PlayerAnimationState.Mining;
     animator.SetBool("Mining", true);
 }
Exemple #29
0
 private void Die()
 {
     _animation = PlayerAnimationState.Die;
     if (!_animationMaster.isAnimationPlaying(_animation))
     {
         _animationMaster.play(_animation);
     }
     Core.schedule(5f, false, newTimer => Game1.endGameMenu("lose"));
 }
Exemple #30
0
        private void ControlPunching()
        {
            _isColliding = false;
            float totalLife;

            if (_fireInput.isPressed)
            {
                _animation      = PlayerAnimationState.Punch;
                _punching       = true;
                _punchStartTime = Time.time;
                _animationMaster.play(_animation);
                entity.scene.findEntity("audio").getComponent <Utilities.AudioController>().PlayerPunch.Play();
                //punchCollider.setEnabled(true);
                //Flags.setFlagExclusive(ref punchCollider.collidesWithLayers, (int)Game1.PhysicsLayers.Enemy);
                var neighborColliders = Physics.boxcastBroadphaseExcludingSelf(_punchCollider);

                foreach (var collider in neighborColliders)
                {
                    if (_punchCollider.overlaps(collider) && collider.entity.getComponent <Utilities.HitController>() != null && CheckYValue(collider))
                    {
                        CheckYValue(collider);
                        var hitCollider = collider.entity.getComponent <Utilities.HitController>();
                        totalLife = hitCollider.GetLife();

                        if (totalLife > 0)
                        {
                            if (_isColliding)
                            {
                                return;
                            }
                            else
                            {
                                Debug.log(this.ToString() + " Damaging:  " + collider.entity.name);
                                _isColliding = true;
                                collider.entity.getComponent <Utilities.HitController>().DoDamage(_damage);
                                CurrentTarget = collider.entity;
                                Score        += 100;
                            }
                        }
                        else if (totalLife == 0)
                        {
                            CurrentTarget = null;
                            collider.unregisterColliderWithPhysicsSystem();
                        }
                    }
                }
            }
            if ((_animationMaster.isAnimationPlaying(PlayerAnimationState.Punch) && ((Time.time - _punchStartTime) >= _punchDuration)))
            {
                _punching       = false;
                _punchStartTime = 0f;
                _animationMaster.pause();
                _animation = PlayerAnimationState.Idle;
                _animationMaster.play(_animation);
            }
        }
Exemple #31
0
 void ProcessCurrentAnimationStatus()
 {
     if (M_Controller_Mark2.MARK2_CHARCONTROLLER.isGrounded)
     {
         if (CurrentMark2AnimeStatee != PlayerAnimationState.FALL &&
             CurrentMark2AnimeStatee != PlayerAnimationState.ATTACK &&
             CurrentMark2AnimeStatee != PlayerAnimationState.LANDING &&
             CurrentMark2AnimeStatee != PlayerAnimationState.TURNING &&
             CurrentMark2AnimeStatee != PlayerAnimationState.STAND_BY)
         {
             if (M_Motor_Mark2.INSTANCE.MoveVector.x != 0)
             {
                 CurrentMark2AnimeStatee = PlayerAnimationState.RUN;
             }
             else
             {
                 CurrentMark2AnimeStatee = PlayerAnimationState.IDLE;
             }
         }
     }
     else
         CurrentMark2AnimeStatee = PlayerAnimationState.FALL;
 }
Exemple #32
0
 void ProcessCurrentAnimationClip()
 {
     if (M_GameMain.GAME_PAUSED)
     {
         foreach (AnimationState state in animation)
         {
             state.speed = 0.0f;
         }
         return;
     }
     if (CurrentMark2AnimeStatee == PlayerAnimationState.IDLE)
     {
         foreach (AnimationState state in animation)
         {
             state.speed = 1.0f;
         }
         animation.CrossFade("idle");
     }
     else if (CurrentMark2AnimeStatee == PlayerAnimationState.RUN)
     {
         foreach (AnimationState state in animation)
         {
             state.speed = 1.5f;
         }
         animation.CrossFade("walking");
     }
     else if (CurrentMark2AnimeStatee == PlayerAnimationState.ATTACK)
     {
         foreach (AnimationState state in animation)
         {
             state.speed = 1.0f;
         }
         animation.Play("hit");
         CurrentMark2AnimeStatee = PlayerAnimationState.STAND_BY;
     }
     else if (CurrentMark2AnimeStatee == PlayerAnimationState.TURNING)
     {
         foreach (AnimationState state in animation)
         {
             state.speed = 1.5f;
         }
         animation.CrossFade("walking");
         if (M_Controller_Mark2.MARK2_CHARCONTROLLER.transform.eulerAngles.y > 240 || M_Controller_Mark2.MARK2_CHARCONTROLLER.transform.eulerAngles.y < 120)
             CurrentMark2AnimeStatee = PlayerAnimationState.IDLE;
     }
     else if (CurrentMark2AnimeStatee == PlayerAnimationState.FALL)
     {
         foreach (AnimationState state in animation)
         {
             state.speed = 1.0f;
         }
         animation.CrossFade("fall");
         if (M_Controller_Mark2.MARK2_CHARCONTROLLER.isGrounded)
             CurrentMark2AnimeStatee = PlayerAnimationState.LANDING;
     }
     else if (CurrentMark2AnimeStatee == PlayerAnimationState.LANDING)
     {
         foreach (AnimationState state in animation)
         {
             state.speed = 1.0f;
         }
         animation.CrossFade("landing", 0.1f);
         CurrentMark2AnimeStatee = PlayerAnimationState.STAND_BY;
     }
     else if (CurrentMark2AnimeStatee == PlayerAnimationState.STAND_BY)
     {
         foreach (AnimationState state in animation)
         {
             state.speed = 1.0f;
         }
         if (!animation.isPlaying)
         {
             CurrentMark2AnimeStatee = PlayerAnimationState.IDLE;
             M_Motor_Mark2.INSTANCE.IsMark2Attacking = false;
             M_MousePlayerController.INSTANCE.IsControllingGUI = false;
         }
     }
 }
Exemple #33
0
 /* *
  * 初期化に関するメソッド
  * */
 //unityを起動するときに実行します
 void Awake()
 {
     INSTANCE = this;
     CurrentMark2AnimeStatee = PlayerAnimationState.STAND_BY;
 }