예제 #1
0
파일: RoleAction.cs 프로젝트: profiles/Fish
 public virtual bool OnInit(tagRoleActionInfo pInfo, RoleActionManager pManager)
 {
     //初始化任务 的数据
     m_pManger   = pManager;
     pActionInfo = pInfo;//客户端在加载的时候 无须判断是否需要进行每日清空
     pConfig     = FishConfig.Instance.m_ActionInfo.m_ActionMap[pActionInfo.ActionID];
     //m_ActionEventIsFinish = (pConfig..FinishValue <= pInfo.ActionValue);
     OnJoinAction();
     return(true);
 }
예제 #2
0
    private Stack <Vector3> path = new Stack <Vector3>();           //兵马俑会移动的路径

    public void Start()
    {
        //初始化运动管理器单例
        action_manager = Singleton <RoleActionManager> .Instance;
    }
예제 #3
0
    /*
     * 兵马俑移动
     * 无参数
     * 无返回值
     * 根据设置的移动路径,一次拿出一个位置去移动,当到达终点判断是否处于攻击状态,然后攻击
     */
    public virtual void Move()
    {
        //判断是否到达终点
        if (GetCurrentPosition() == destination)
        {
            // Debug.Log("到达终点"+destination);
            isMoving = false;
            StopMoveAnimation();

            //之后可以智能判断周边是否需要攻击
            MapController.instance.RedoOrder(destination);//取消对目的地的锁
            if (willAttack)
            {
                //如果是攻击状态在移动结束后需要攻击
                //得到伤害
                float hurt = GetChessHurt(victim);
                //攻击
                if (action_manager == null)
                {
                    action_manager = gameObject.AddComponent <RoleActionManager>();
                }
                isAttacking = true;

                action_manager.Attack(gameObject, victim, hurt);
                Debug.Log("伤害" + hurt);
                GameObject tempGo = victim ?? null;
                if (tempGo == null)
                {
                    return;
                }
                if (victim.GetComponent <Chess>().isMoving)
                {
                    victim.GetComponent <Chess>().attackBy = true;
                }

                if (victim.GetComponent <Chess>().willAttack == false)
                {
                    Singleton <PlayerController> .Instance.Attack(victim, this.gameObject);
                }
            }
            else
            {
                isAttacking = false;
                AutoAttacks();
            }
        }
        else
        {
            //得到下一个位置
            if (chessType == ChessType.Car)
            {
                nextDestination = gameObject.GetComponent <CarChess>().GetNextStep(GetCurrentPosition(), destination);
            }
            else
            {
                nextDestination = mapController.GetNextStep(GetCurrentPosition(), destination);
            }
            //Debug.Log("下一个移动到的位置" + nextDestination);
            //如果该位置是合法的,走向该位置
            if (MapController.instance.CanWalk(nextDestination))
            {
                //移动到该位置
                MoveToPosition(nextDestination);
            }
            else
            {
                //       Debug.Log("该位置不合法,应该停在当前位置");
                isMoving    = false;
                willAttack  = false;
                isAttacking = false;
                StopMoveAnimation();
            }
        }
    }