Esempio n. 1
0
 public StateMovingBetweenStars(StateContex contex, GameObject tako) : base(contex, tako)
 {
     Name     = StateName.MovingBetweenStars;
     OnEnter += Init;
     update  += Update;
     OnExit  += AdjustTakoModelOnExitState;
 }
Esempio n. 2
0
        public void Update(StateContex contex)
        {
            contex.weapon = bag.GetNowWeapon();
            soldierState  = soldierState.NextState(_this, animatorHandler, contex);

            contex.characterType = charactType;
            contex.weapon.Update(_this, animatorHandler, contex);
        }
Esempio n. 3
0
 public TakoState(StateContex stateContex, GameObject tako) : base(stateContex)
 {
     this.tako       = tako;
     this.takoScript = this.tako.GetComponent <TakoController>();
     update          = UsualUpdate;
     OnEnter         = UsualEnterEvent;
     OnExit          = UsualExitEvent;
 }
Esempio n. 4
0
            public StateWaitingForKineticPowerEnd(StateContex contex, GameObject tako) : base(contex, tako)
            {
                Name     = StateName.WaitingForKineticPowerEnd;
                OnEnter += OnEnterEvent;
                OnExit  += OnExitEvent;

                update += CheckMovingLand;
            }
Esempio n. 5
0
 public StateNormal(StateContex stateContex, GameObject tako) : base(stateContex, tako)
 {
     Name            = StateName.Normal;
     facingDirection = Direction.NONE;
     OnEnter        += CheckAndSelectStarInFacingCell;
     OnEnter        += takoScript.ClearAnimationFlag;
     update         += UpdateByCommand;
 }
Esempio n. 6
0
 public abstract void Update(GameObject gameObject, AnimatorHandler animatorHandler, StateContex contex);
Esempio n. 7
0
 public StateStayingGoal(StateContex contex, GameObject tako) : base(contex, tako)
 {
     Name = StateName.StayingGoal;
 }
Esempio n. 8
0
 public StateFollowing(StateContex contex, GameObject camera) : base(contex, camera)
 {
     Name     = StateName.Following;
     OnEnter += Init;
 }
Esempio n. 9
0
 public StateCommandDisable(StateContex contex, GameObject tako) : base(contex, tako)
 {
     Name = StateName.CommandDisable;
 }
Esempio n. 10
0
 private float speed = 1.0f; // per sec
 public StateFloating(StateContex contex, GameObject camera) : base(contex, camera)
 {
     Name    = StateName.Floating;
     update += MoveByKeyInput;
 }
        public override SoldierStateBase NextState(GameObject gameObject, AnimatorHandler animatorHandler, StateContex contex)
        {
            //float h = (float)contex.Get(DTSAnimation.BLEND_TREE_2D_PARAM_NAME_1);
            //float v = (float)contex.Get(DTSAnimation.BLEND_TREE_2D_PARAM_NAME_2);

            //animatorHandler.animator.SetFloat(DTSAnimation.BLEND_TREE_2D_PARAM_NAME_1, h);
            //animatorHandler.animator.SetFloat(DTSAnimation.BLEND_TREE_2D_PARAM_NAME_2, v);


            if (contex.Check(EContexParam.END_CROUCH))
            {
                soldierStateWalk.Enter(gameObject, animatorHandler, contex);
                return(soldierStateWalk);
            }

            if (contex.Check(EContexParam.DUMP) && dump.CheckAndRun())
            {
                contex.preState = soldierStateCrouch;
                soldierStateJump.Enter(gameObject, animatorHandler, contex);
                return(soldierStateJump);
            }

            return(soldierStateCrouch);
        }
Esempio n. 12
0
        public override void Update(GameObject gameObject, AnimatorHandler animatorHandler, StateContex contex)
        {
            if (nextAllowUseSkillTime > Time.time * 1000)
            {
                return;
            }

            // 换子弹
            if (contex.Check(EContexParam.RELOAD) && reload.CheckAndRun())
            {
                nextAllowUseSkillTime = Time.time * 1000 + reload.LockTime;
                ReloadBullet(animatorHandler);
                return;
            }

            // 单发射击
            if (contex.Check(EContexParam.SHOOT))
            {
                if (BulletCountFirst.val >= 1 && shoot.CheckAndRun())
                {
                    nextAllowUseSkillTime = Time.time * 1000 + shoot.LockTime;
                    Fire(animatorHandler, contex.characterType);
                    return;
                }
            }
        }
        public override void Enter(GameObject gameObject, AnimatorHandler animatorHandler, StateContex contex)
        {
            string animation = contex.weapon.GetDumpAnimationName();

            if (animation != string.Empty)
            {
                // 设置角色姿态 为 站立
                animatorHandler.animator.SetInteger(DTSAnimation.POSE_PARAM, DTSAnimation.ANIMATION_STATE_STAND);

                // 播放使用 该武器类型 的 跳跃 动画
                animatorHandler.PlayAnimation(animation, 0);
                gameObject.GetComponent <Rigidbody>().AddForce(gameObject.transform.up * force);

                preState = contex.preState;

                dumpTime = Time.time * 1000;
                MemeryCacheMgr.Instance.Set(gameObject.name.ToString() + "#" + DTSKeys.DROP_DOWN, false);
            }
        }
Esempio n. 14
0
        public override void Update(GameObject gameObject, AnimatorHandler animatorHandler, StateContex contex)
        {
            if (nextAllowUseSkillTime > Time.time * 1000)
            {
                return;
            }

            if (contex.Check(EContexParam.SHOOT) && leftAttack.CheckAndRun())
            {
                LeftAttack(animatorHandler);

                if (contex.characterType == Entity.CharacterType.PLAYER)
                {
                    EventMgr.Instance.EventTrigger(EventName.PLAYER_KNIFE_ATTACK, 30);
                }
                return;
            }

            if (contex.Check(EContexParam.SHOOT_BURST) && rightAttack.CheckAndRun())
            {
                RightAttack(animatorHandler);

                if (contex.characterType == Entity.CharacterType.PLAYER)
                {
                    EventMgr.Instance.EventTrigger(EventName.PLAYER_KNIFE_ATTACK, 60);
                }
                return;
            }
        }
Esempio n. 15
0
        public override void Enter(GameObject gameObject, AnimatorHandler animatorHandler, StateContex contex)
        {
            Transform weaponMount = Tools.FindChildrenTransform(gameObject, "Bip001 Spine");

            ObjectPoolMgr.Instance.LoadGameObject("model/" + modelName, (obj) =>
            {
                weaponModel = obj;

                obj.name             = modelName;
                obj.transform.parent = weaponMount;

                obj.transform.localScale       = weaponConf.localScale;
                obj.transform.localPosition    = weaponConf.localPosition;
                obj.transform.localEulerAngles = weaponConf.localRotation;

                Transform leftHandIKTransform  = Tools.FindChildrenTransform(gameObject, IKPosition.IKLeftHand);
                Transform rightHandIKTransform = Tools.FindChildrenTransform(gameObject, IKPosition.IKRightHand);

                if (leftHandIKTransform)
                {
                    leftHandIKTransform.localPosition = weaponConf.leftHandIKPositon;
                }
                if (rightHandIKTransform)
                {
                    rightHandIKTransform.localPosition = weaponConf.rightHandIKPositon;
                }
            });
            animatorHandler.animator.SetInteger(DTSAnimation.WEAPON_PARAM, DTSAnimation.ANIMATION_STATE_WEAPON_KNIFE);
        }
Esempio n. 16
0
        public override SoldierStateBase NextState(GameObject gameObject, AnimatorHandler animatorHandler, StateContex contex)
        {
            if (contex.Check(EContexParam.END_RUN))
            {
                soldierStateWalk.Enter(gameObject, animatorHandler, contex);
                return(soldierStateWalk);
            }

            if (contex.Check(EContexParam.DUMP) && dump.CheckAndRun())
            {
                contex.preState = soldierStateRun;
                soldierStateJump.Enter(gameObject, animatorHandler, contex);
                return(soldierStateJump);
            }
            return(soldierStateRun);
        }
Esempio n. 17
0
        public override void Enter(GameObject gameObject, AnimatorHandler animatorHandler, StateContex contex)
        {
            string animation = contex.weapon.GetStandAnimationName();

            if (animation != string.Empty)
            {
                animatorHandler.animator.SetInteger(DTSAnimation.POSE_PARAM, DTSAnimation.ANIMATION_STATE_STAND);
                animatorHandler.PlayAnimation(animation, 0);
                animatorHandler.PlayAnimation(animation, 1);
            }
        }
Esempio n. 18
0
 public CameraState(StateContex contex, GameObject camera) : base(contex)
 {
     this.camera  = camera;
     cameraScript = camera.GetComponent <InGameMainCameraController>();
     update      += GetScreenInfo;
 }
Esempio n. 19
0
        public override void Update(GameObject gameObject, AnimatorHandler animatorHandler, StateContex contex)
        {
            if (nextAllowUseSkillTime > Time.time * 1000)
            {
                return;
            }

            // 换子弹
            if (contex.Check(EContexParam.RELOAD) && reload.CheckAndRun())
            {
                nextAllowUseSkillTime = Time.time * 1000 + reload.LockTime;
                ReloadBullet(animatorHandler);
                return;
            }

            // 单发射击
            if (contex.Check(EContexParam.SHOOT))
            {
                if (BulletCountFirst.val >= 1 && shoot.CheckAndRun())
                {
                    nextAllowUseSkillTime = Time.time * 1000 + shoot.LockTime;
                    Fire(animatorHandler, contex.characterType);
                    return;
                }
            }

            // 三发射击
            if (contex.Check(EContexParam.SHOOT_BURST))
            {
                if (BulletCountFirst.val >= 3 && shootBrush.CheckAndRun())
                {
                    MonoMgr.Instance.StartCoroutine(MultiFire(3, 0.1f, animatorHandler, contex.characterType));
                    nextAllowUseSkillTime = Time.time * 1000 + shootBrush.LockTime;
                    return;
                }
            }
        }
        public override void Enter(GameObject gameObject, AnimatorHandler animatorHandler, StateContex contex)
        {
            string animation = contex.weapon.GetCrouchAnimationName();

            if (animation != string.Empty)
            {
                // 设置角色姿态 为 蹲下
                animatorHandler.animator.SetInteger(DTSAnimation.POSE_PARAM, DTSAnimation.ANIMATION_STATE_CROUCH);
                // 播放使用 该武器类型 的 站立动画
                animatorHandler.PlayAnimation(animation, 0);
                animatorHandler.PlayAnimation(animation, 1);
            }
        }
Esempio n. 21
0
        public override void Update(GameObject gameObject, AnimatorHandler animatorHandler, StateContex contex)
        {
            if (nextAllowUseSkillTime > Time.time * 1000)
            {
                return;
            }

            // 换子弹
            if (contex.Check(EContexParam.RELOAD) && reload.CheckAndRun())
            {
                nextAllowUseSkillTime = Time.time * 1000 + reload.LockTime;
                ReloadBullet(animatorHandler);
                return;
            }

            // 单发射击
            if (contex.Check(EContexParam.SHOOT))
            {
                if (BulletCountFirst.val >= 1 && shoot.CheckAndRun())
                {
                    nextAllowUseSkillTime = Time.time * 1000 + shoot.LockTime;
                    Fire(animatorHandler, contex.characterType);
                    return;
                }
            }

            // 三发射击
            if (contex.Check(EContexParam.SHOOT_BURST))
            {
                if (BulletCountFirst.val >= 3 && shootBrush.CheckAndRun())
                {
                    MonoMgr.Instance.StartCoroutine(MultiFire(3, 0.1f, animatorHandler, contex.characterType));
                    nextAllowUseSkillTime = Time.time * 1000 + shootBrush.LockTime;
                    return;
                }
            }

            if (contex.Check(EContexParam.SHOOT_LINE) && shootLine.CheckAndRun() && camera != null)
            {
                if (Physics.Raycast(camera.transform.position, camera.transform.forward, out RaycastHit hit, Mathf.Infinity))
                {
                    EventMgr.Instance.EventTrigger(EventName.ATTACK_YUN, new SkillAttackYunBullet
                    {
                        position = weaponModel.transform.position,
                        direct   = hit.point - weaponModel.transform.position,
                        force    = 100,
                    });
                }
            }
        }
        public override SoldierStateBase NextState(GameObject gameObject, AnimatorHandler animatorHandler, StateContex contex)
        {
            try
            {
                bool inTheFloor = (bool)MemeryCacheMgr.Instance.Get(gameObject.name.ToString() + "#" + DTSKeys.DROP_DOWN);

                if (inTheFloor && Time.time * 1000 - dumpTime > 500)
                {
                    string animation = contex.weapon.GetDropDownAnimationName();
                    animatorHandler.PlayAnimation(animation, 0);
                    preState.Enter(gameObject, animatorHandler, contex);
                    return(preState);
                }
                else
                {
                    return(soldierStateJump);
                }
            }
            catch (Exception ex)
            {
                Debug.Log("in the floor boolean parse fail. " + ex.ToString());
                return(preState);
            }
        }
Esempio n. 23
0
 public StateMovingFromGoalToStart(StateContex contex, GameObject camera) : base(contex, camera)
 {
     Name     = StateName.MovingFromGoalToStart;
     OnEnter += Init;
 }
Esempio n. 24
0
        public override void Enter(GameObject gameObject, AnimatorHandler animatorHandler, StateContex contex)
        {
            Transform weaponMount = Tools.FindChildrenTransform(gameObject, "Bip001 Spine");

            ObjectPoolMgr.Instance.LoadGameObject("model/" + modelName, (obj) =>
            {
                weaponModel = obj;
                RecoverBackup();

                weaponFire = new WeaponFire(this.camera,
                                            belongSoldierType,
                                            weaponConf.recoilUp,
                                            weaponConf.recoilLeft,
                                            weaponConf.recoilRight,
                                            weaponConf.horizontalRevert,
                                            weaponConf.verticalRevert,
                                            weaponConf.hurt1
                                            );
                weaponFire.SetWeapon(weaponModel);

                obj.name             = modelName;
                obj.transform.parent = weaponMount;

                obj.transform.localScale       = weaponConf.localScale;
                obj.transform.localPosition    = weaponConf.localPosition;
                obj.transform.localEulerAngles = weaponConf.localRotation;

                Transform leftHandIKTransform  = Tools.FindChildrenTransform(gameObject, IKPosition.IKLeftHand);
                Transform rightHandIKTransform = Tools.FindChildrenTransform(gameObject, IKPosition.IKRightHand);

                leftHandIKTransform.localPosition  = weaponConf.leftHandIKPositon;
                rightHandIKTransform.localPosition = weaponConf.rightHandIKPositon;
            });

            animatorHandler.animator.SetInteger(DTSAnimation.WEAPON_PARAM, DTSAnimation.ANIMATION_STATE_WEAPON_HEAVY);
        }
 // 计算下一个状态,可能用户输入驱动,也可能是AI计算的结果
 public abstract SoldierStateBase NextState(GameObject gameObject, AnimatorHandler animatorHandler, StateContex contex);