Esempio n. 1
0
 void DoAI()
 {
     if (currentPlayerAI != null)
     {
         currentPlayerAI.DoAI();
     }
 }
Esempio n. 2
0
    void Update()
    {
        //如果角色没有AI 直接返回
        if (CurrRoleAI == null)
        {
            return;
        }
        CurrRoleAI.DoAI();

        if (CurrRoleFSMMgr != null)
        {
            CurrRoleFSMMgr.OnUpdate();
        }


        if (CharacterController == null)
        {
            return;
        }

        //让角色贴着地面
        if (!CharacterController.isGrounded)
        {
            CharacterController.Move((transform.position + new Vector3(0, -1000, 0)) - transform.position);
        }

        if (CurrRoleType == RoleType.MainPlayer)
        {
            CameraAutoFollow();
        }
    }
Esempio n. 3
0
 // Update is called once per frame
 void Update()
 {
     FSM.OnUpdate();
     if (CurRoleAI == null)
     {
         return;
     }
     CurRoleAI.DoAI();
     if (isInit)
     {
         isInit = false;
         if (CurRoleType == RoleType.Monster)
         {
             ToIdle(IdleType.IdleFight);
         }
         else
         {
             ToIdle(IdleType.IdleNormal);
         }
     }
     if (CurRoleType == RoleType.MainPlayer)
     {
         CameraAutoFollow();
     }
     AutoSmallMap();
 }
        protected virtual void OnUpdate()
        {
            if (CurRoleAI != null)
            {
                CurRoleAI.DoAI();
            }
            if (StateMachine.CurrentRoleState != null)
            {
                StateMachine.CurrentRoleState.OnUpdate();
            }
            Test = StateMachine.CurrentRoleStateType;

            if (GameSceneCtrl.Instance.GetCurLevelProcedure() == LevelProcedure.HeroEditor)
            {
                //是否显示简介
                if (m_RoleOperationsStatus.CurState == RoleOperationsStatus.NoOperations)
                {
                    if (m_Enter)
                    {
                        m_PointDownTimer += Time.deltaTime;
                        if (m_PointDownTimer > 1.5f)
                        {
                            m_RoleOperationsStatus.ChangeState(RoleOperationsStatus.ShowIntro);
                        }
                    }
                }
            }
        }
 protected virtual void OnUpdate()
 {
     if (m_AI != null)
     {
         m_AI.DoAI();
     }
     if (StateMachine.CurrentRoleState != null)
     {
         StateMachine.CurrentRoleState.OnUpdate();
     }
 }
Esempio n. 6
0
    void Update()
    {
        if (CurrRoleFSMMgr != null)
        {
            CurrRoleFSMMgr.OnUpdate();
        }

        //如果角色没有AI 直接返回
        if (CurrRoleAI == null)
        {
            return;
        }
        CurrRoleAI.DoAI();

        if (CharacterController == null)
        {
            return;
        }

        //让角色贴着地面
        if (!CharacterController.isGrounded)
        {
            CharacterController.Move((transform.position + new Vector3(0, -1000, 0)) - transform.position);
        }

        if (Input.GetMouseButtonUp(1))
        {
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            RaycastHit hit;
            if (Physics.Raycast(ray, out hit, Mathf.Infinity, 1 << LayerMask.NameToLayer("Item")))
            {
                BoxCtrl boxCtrl = hit.collider.GetComponent <BoxCtrl>();
                if (boxCtrl != null)
                {
                    boxCtrl.Hit();
                }
            }
        }

        //让角色贴着地面
        if (!CharacterController.isGrounded)
        {
            CharacterController.Move((transform.position + new Vector3(0, -1000, 0)) - transform.position);
        }

        if (CurrRoleType == RoleType.MainPlayer)
        {
            CameraAutoFollow();
        }

        AutoSamllMap();
    }
Esempio n. 7
0
        private void Update()
        {
            if (IsDead)
            {
                return;
            }
            if (Input.GetKeyDown(KeyCode.A))
            {
                ToJump();
            }

            if (Input.GetKeyDown(KeyCode.B))
            {
                ToHurt(5);
            }
            if (Input.touchCount == 1)
            {
                if (!m_IsPress)
                {
                    ToJump();
                }
                m_IsPress = true;
            }
            if (Input.touchCount == 0)
            {
                m_IsPress = false;
            }

            m_PhyCtroller.OnUpdate();
            CheckSide();
            CheckAbove();
            CheckBelow();
            Rigidbody.velocity = new Vector2(HorizontalVelocity, Rigidbody.velocity.y);
            if (HorizontalVelocity < 0)
            {
                transform.eulerAngles = new Vector3(0, -180, 0);
            }
            else
            {
                transform.eulerAngles = new Vector3(0, 0, 0);
            }
            transform.position = new Vector3(transform.position.x, transform.position.y, -1.5f);
            if (CurRoleAI == null)
            {
                return;
            }
            CurRoleAI.DoAI();
        }
Esempio n. 8
0
    void Update()
    {
        //如果当前角色没有AI,直接返回
        if (CurrRoleAI == null)
        {
            return;
        }
        CurrRoleAI.DoAI();

        if (CurrRoleFSMMgr != null)
        {
            CurrRoleFSMMgr.OnUpdate();
        }

        if (CharacterController == null)
        {
            return;
        }

        //让角色贴着地面
        if (!CharacterController.isGrounded)
        {
            CharacterController.Move((transform.position + new Vector3(0, -1000, 0)) - transform.position);
        }


        //if (Input.GetMouseButtonUp(1))
        //{
        //    Collider[] colliderArr = Physics.OverlapSphere(transform.position, 3, 1 << LayerMask.NameToLayer("Item"));
        //    if (colliderArr.Length > 0)
        //    {
        //        for (int i = 0; i < colliderArr.Length; i++)
        //        {
        //            Debug.Log("找到了附近的箱子" + colliderArr[i].gameObject.name);
        //        }
        //    }
        //}

        if (Input.GetMouseButtonUp(1))
        {
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            //RaycastHit[] hitArr = Physics.RaycastAll(ray, Mathf.Infinity, 1 << LayerMask.NameToLayer("Item"));

            //if (hitArr.Length > 0)
            //{
            //    for (int i = 0; i < hitArr.Length; i++)
            //    {
            //        Debug.Log("找到了" + hitArr[i].collider.gameObject.name);
            //    }
            //}

            RaycastHit hit;
            if (Physics.Raycast(ray, out hit, Mathf.Infinity, 1 << LayerMask.NameToLayer("Item")))
            {
                BoxCtrl boxCtrl = hit.collider.GetComponent <BoxCtrl>();
                if (boxCtrl != null)
                {
                    boxCtrl.Hit();
                }
            }
        }

        //让角色贴着地面
        if (!CharacterController.isGrounded)
        {
            CharacterController.Move((transform.position + new Vector3(0, -1000, 0)) - transform.position);
        }

        if (CurRoleType == RoleType.MainPlayer)
        {
            CameraAutoFollow();
        }

        //if (Input.GetKeyUp(KeyCode.R))
        //{
        //    ToRun();
        //}
        //else if (Input.GetKeyUp(KeyCode.N))
        //{
        //    ToIdle();
        //}
        //else if (Input.GetKeyUp(KeyCode.A))
        //{
        //    ToAttack();
        //}
        //else if (Input.GetKeyUp(KeyCode.H))
        //{
        //    ToHurt();
        //}
        //else if (Input.GetKeyUp(KeyCode.D))
        //{
        //    ToDie();
        //}
    }
Esempio n. 9
0
    void Update()
    {
        //如果没有AI就不执行任何行为
        if (RoleAI == null)
        {
            return;
        }

        //执行AI行为
        RoleAI.DoAI();

        Vector2 vec2 = Camera.main.WorldToScreenPoint(this.gameObject.transform.position);

        //判断角色是否再主相机内,如果不在就将其头顶UI隐藏,反之打开
        if (IsInView(transform.position))
        {
            if (m_HeadBar != null)
            {
                if (!m_HeadBar.activeSelf)
                {
                    m_HeadBar.SetActive(true);
                }
            }
        }
        else
        {
            if (m_HeadBar != null)
            {
                if (m_HeadBar.activeSelf)
                {
                    m_HeadBar.SetActive(false);
                }
            }
        }

        //每帧执行有限状态机的执行状态
        if (RoleFSMMgr != null)
        {
            RoleFSMMgr.OnUpdate();
        }

        if (CharacterCtrl == null)
        {
            return;
        }

        #region 主角移动
        //如果角色没有着地,就迅速让其着地
        if (!CharacterCtrl.isGrounded)
        {
            CharacterCtrl.Move(transform.position + new Vector3(0, -1000, 0) - transform.position);
        }
        #endregion

        //摄像机只跟随主角
        if (CurrRoleType == RoleType.MainPlayer)
        {
            #region 摄像机的跟随和旋转
            CameraAutoFllow();
            #endregion
        }
    }