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);
                        }
                    }
                }
            }
        }
        public override void EnterState(RoleStateType lastStateType)
        {
            if (_parentObj.GetGameObject() == null)
            {
                return;
            }

            var animation = _parentObj.GetGameObject().GetComponent <Animation>();

            animation.Play("stand");
        }
Exemple #3
0
    /// <summary>
    /// 构造
    /// </summary>
    /// <param name="rolectrl"></param>
    public RoleFSMMgr(RoleCtrl rolectrl)
    {
        RoleCtrl = rolectrl;

        RoleStateType = RoleStateType.None;

        m_RoleStateDic = new Dictionary <RoleStateType, RoleStateAbstract>();
        //初始化角色状态机字典
        m_RoleStateDic.Add(RoleStateType.None, new RoleStateNone(this));
        m_RoleStateDic.Add(RoleStateType.Idle, new RoleStateIdle(this));
        m_RoleStateDic.Add(RoleStateType.Run, new RoleStateRun(this));
        m_RoleStateDic.Add(RoleStateType.Hurt, new RoleStateHurt(this));
        m_RoleStateDic.Add(RoleStateType.Die, new RoleStateDie(this));
        m_RoleStateDic.Add(RoleStateType.Attack, new RoleStateAttack(this));

        if (m_RoleStateDic.ContainsKey(RoleStateType))
        {
            m_RoleState = m_RoleStateDic[RoleStateType];
        }
    }
Exemple #4
0
        /// <summary>
        /// 结交侠客
        /// </summary>
        /// <param name="id">Identifier.</param>
        public void InviteRole(int id)
        {
            bool     invited = false;
            RoleData role    = null;

            db = OpenDb();
            SqliteDataReader sqReader = db.ExecuteQuery("select Id, RoleId, State from RolesTable where Id = " + id);

            if (sqReader.Read())
            {
                role = JsonManager.GetInstance().GetMapping <RoleData>("RoleDatas", sqReader.GetString(sqReader.GetOrdinal("RoleId")));
                RoleStateType state = (RoleStateType)sqReader.GetInt32(sqReader.GetOrdinal("State"));
                if (state == RoleStateType.NotRecruited)
                {
                    sqReader = db.ExecuteQuery("select * from WeaponsTable where WeaponId = '" + role.ResourceWeaponDataId + "' and BeUsingByRoleId == '' and BelongToRoleId = '" + currentRoleId + "'");
                    if (sqReader.Read())
                    {
                        //删掉兵器
                        db.ExecuteQuery("delete from WeaponsTable where Id = " + sqReader.GetInt32(sqReader.GetOrdinal("Id")));
                        //结交侠客
                        db.ExecuteQuery("update RolesTable set State = " + ((int)RoleStateType.OutTeam) + ", SeatNo = 888 where Id = " + id);
                        invited = true;
                    }
                    else
                    {
                        AlertCtrl.Show("你的兵器匣里并没有称手的兵器!", null);
                    }
                }
                else
                {
                    AlertCtrl.Show("你们已经结识!", null);
                }
            }
            db.CloseSqlConnection();
            if (invited && role != null)
            {
                Statics.CreatePopMsg(Vector3.zero, string.Format("你与<color=\"#FFFF00\">{0}</color>撮土为香,结成八拜之交!", role.Name), Color.white, 30);
                GetRolesOfWinShopPanelData(role.HometownCityId);
            }
        }
Exemple #5
0
    /// <summary>
    ///  切换状态
    /// </summary>
    /// <param name="newState">新的状态</param>
    public void ChangeState(RoleStateType newState)
    {
        if (newState == RoleStateType)
        {
            return;
        }

        if (m_RoleState == null)
        {
            return;
        }
        //离开之前的状态
        m_RoleState.OnLeave();

        //将当前状态更新为新的状态
        RoleStateType = newState;

        m_RoleState = m_RoleStateDic[newState];

        //调用新状态的进入方法
        m_RoleState.OnEnter();
    }
Exemple #6
0
        /// <summary>
        /// 直接用工坊资源结交侠客
        /// </summary>
        /// <param name="id">Identifier.</param>
        public void InviteRoleWithResources(int id)
        {
            bool     invited = false;
            RoleData role    = null;

            db = OpenDb();
            SqliteDataReader sqReader = db.ExecuteQuery("select Id, RoleId, State from RolesTable where Id = " + id);

            if (sqReader.Read())
            {
                role = JsonManager.GetInstance().GetMapping <RoleData>("RoleDatas", sqReader.GetString(sqReader.GetOrdinal("RoleId")));
                RoleStateType state = (RoleStateType)sqReader.GetInt32(sqReader.GetOrdinal("State"));
                if (state == RoleStateType.NotRecruited)
                {
                    //兵器匣里并没有需要的兵器
                    WeaponData          weapon = JsonManager.GetInstance().GetMapping <WeaponData>("Weapons", role.ResourceWeaponDataId);
                    List <ResourceData> needs  = new List <ResourceData>();
                    ResourceData        need;
                    ResourceData        find;
                    for (int i = 0; i < weapon.Needs.Count; i++)
                    {
                        need = weapon.Needs[i];
                        find = needs.Find(item => item.Type == need.Type);
                        if (find == null)
                        {
                            needs.Add(new ResourceData(need.Type, need.Num));
                        }
                        else
                        {
                            find.Num += need.Num;
                        }
                    }
                    sqReader = db.ExecuteQuery("select Id, ResourcesData from WorkshopResourceTable where BelongToRoleId = '" + currentRoleId + "'");
                    List <ResourceData> resources = null;
                    int resourceId = 0;
                    if (sqReader.Read())
                    {
                        resourceId = sqReader.GetInt32(sqReader.GetOrdinal("Id"));
                        resources  = JsonManager.GetInstance().DeserializeObject <List <ResourceData> >(sqReader.GetString(sqReader.GetOrdinal("ResourcesData")));
                    }
                    db.CloseSqlConnection();

                    if (resources != null)
                    {
                        bool   canAdd = true;
                        string msg    = "";
                        for (int i = 0; i < needs.Count; i++)
                        {
                            need = needs[i];
                            find = resources.Find(item => item.Type == need.Type);
                            if (find != null && find.Num >= need.Num)
                            {
                                find.Num -= need.Num;
                            }
                            else
                            {
                                canAdd = false;
                                msg    = string.Format("{0}不足!", Statics.GetResourceName(need.Type));
                                break;
                            }
                        }
                        if (canAdd)
                        {
                            db = OpenDb();
                            db.ExecuteQuery("update WorkshopResourceTable set ResourcesData = '" + JsonManager.GetInstance().SerializeObject(resources) + "' where Id = " + resourceId);
                            //结交侠客
                            db.ExecuteQuery("update RolesTable set State = " + ((int)RoleStateType.OutTeam) + ", SeatNo = 888 where Id = " + id);
                            invited = true;
                            db.CloseSqlConnection();
                        }
                        else
                        {
                            AlertCtrl.Show(msg, null);
                        }
                    }
                }
                else
                {
                    AlertCtrl.Show("你们已经结识!", null);
                }
            }
            db.CloseSqlConnection();
            if (invited && role != null)
            {
                Statics.CreatePopMsg(Vector3.zero, string.Format("你与<color=\"#FFFF00\">{0}</color>撮土为香,结成八拜之交!", role.Name), Color.white, 30);
                GetRolesOfWinShopPanelData(role.HometownCityId);
            }
        }
        public override void EnterState(RoleStateType lastStateType)
        {
            var animation = _parentObj.GetGameObject().GetComponent <Animation>();

            animation.Play("move");
        }