Esempio n. 1
0
        private bool onClickCommand(CommandBase command)
        {
            if (command is ClickCommand)
            {
                ClickCommand clickCommand = command as ClickCommand;

                if (clickCommand.IsValid)
                {
                    bool isPutSuccessful = PutChess(clickCommand.Board_X, clickCommand.Board_Y);

                    //Model.PrintBoard();

                    RoleMgr.ChangeNextRole();

                    int boardScore = DebugEvaluation.GetScore(Model, MyChessType);
                    Console.WriteLine($"ChessType = {MyChessType.ToString()}   Board Score = {boardScore.ToString()}");

                    return(true);
                }
                else
                {
                    Console.WriteLine($"Not valid position");

                    return(false);
                }
            }
            else
            {
                Console.WriteLine("command is not ClickCommand");

                return(false);
            }
        }
Esempio n. 2
0
 public void OnCollisionEnter(Collision col)
 {
     //击中物体
     GameObject target = col.gameObject;
     RoleMgr    role   = target.GetComponent <RoleMgr>();
     //发送服务器受伤状况
 }
Esempio n. 3
0
 public HumanPlayer(String name, Form1 view, Model model, RoleMgr roleMgr, ChessType chessType) : base(name, view, model, roleMgr, chessType)
 {
     addCommand("PreviousActionCommand", isAllowPreviousActionCommand, onPreviousActionCommand);
     addCommand("ChangeComputerPlayCommand", isAllowChangeComputerPlayCommand, onChangeComputerPlayCommand);
     addCommand("LoadBoardCommand", isAllowLoadBoardCommand, onLoadBoardCommand);
     addCommand("ClickCommand", isAllowClickCommand, onClickCommand);
 }
Esempio n. 4
0
        public override void onMyTurn()
        {
            base.onMyTurn();

            if (TotalTurn == 0)
            {
                System.Console.WriteLine($"AI Turn 1");
                bool isPutSuccessful = PutChess(GameDef.board_cell_length / 2, GameDef.board_cell_length / 2);

                RoleMgr.ChangeNextRole();
            }
            else
            {
                MinMaxSearchCount = 0;
                MinMaxSearchInfo bestPosInfo = MinMaxSearch(Model, MyChessType, true, 0, int.MinValue, int.MaxValue);

                System.Console.WriteLine($"MinMaxSearchCount = {MinMaxSearchCount.ToString()}");
                System.Console.WriteLine($"SearchHasResultCount = {SearchHasResultCount.ToString()}");
                System.Console.WriteLine($"Turn: {(TotalTurn + 1).ToString()}  {Name} Y = {bestPosInfo.Y.ToString()} X = {bestPosInfo.X.ToString() } Score = {bestPosInfo.Score.ToString()}");
                bestPosInfo.Model.PrintBoard();

                bool isPutSuccessful = PutChess(bestPosInfo.X, bestPosInfo.Y);
                RoleMgr.ChangeNextRole();
            }
        }
Esempio n. 5
0
    public void CastSkill(int skillIndex = -1)
    {
        var roleGameOE = RoleMgr.GetInstance().GetMainRole();
        var roleInfo   = roleGameOE.GetComponent <RoleInfo>();
        var skillID    = SkillManager.GetInstance().GetSkillIDByIndex(skillIndex);

        string assetPath      = ResPath.GetRoleSkillResPath(skillID);
        bool   isNormalAttack = skillIndex == -1;//普通攻击

        if (!isNormalAttack)
        {
            SkillManager.GetInstance().ResetCombo();//使用非普攻技能时就重置连击索引
        }
        var uid = SceneMgr.Instance.EntityManager.GetComponentData <UID>(roleGameOE.Entity);
        Action <TimelineInfo.Event> afterAdd = null;

        if (isNormalAttack)
        {
            //普攻的话增加连击索引
            afterAdd = (TimelineInfo.Event e) =>
            {
                if (e == TimelineInfo.Event.AfterAdd)
                {
                    SkillManager.GetInstance().IncreaseCombo();
                }
            };
        }
        var timelineInfo = new TimelineInfo {
            ResPath = assetPath, Owner = roleGameOE.Entity, StateChange = afterAdd
        };

        TimelineManager.GetInstance().AddTimeline(uid.Value, timelineInfo, SceneMgr.Instance.EntityManager);
    }
Esempio n. 6
0
        public override void onMyTurn()
        {
            base.onMyTurn();

            if (Model.PrepareCheckedChessType == MyChessType)
            {
                if (ConnectStrategy.IsWin(MyChessType))
                {
                    View.ShowMsg($"{Name.Split('_')[0]} ({Name.Split('_')[3]}) WIN !!!");
                    System.Console.WriteLine($"{Name.Split('_')[0]} ({Name.Split('_')[3]}) WIN !!!");
                }
                else if (ConnectStrategy.IsTie())
                {
                    System.Console.WriteLine($"It's tie !!!");
                    View.ShowMsg($"It's tie !!!");
                }
                else
                {
                    RoleMgr.ChangeNextRole();
                }
            }
            else
            {
                System.Console.WriteLine($"{Name} judge error type");
            }
        }
Esempio n. 7
0
    protected override void OnUpdate()
    {
        var requestArray = Group.GetComponentDataArray <NameboardSpawnRequest>();
        var entityArray  = Group.GetEntityArray();

        var spawnRequests = new NameboardSpawnRequest[requestArray.Length];

        for (var i = 0; i < requestArray.Length; i++)
        {
            spawnRequests[i] = requestArray[i];
            PostUpdateCommands.DestroyEntity(entityArray[i]);
        }

        for (var i = 0; i < spawnRequests.Length; i++)
        {
            var request = spawnRequests[i];
            GameObjectEntity nameboardGOE = m_world.Spawn <GameObjectEntity>(ResMgr.GetInstance().GetPrefab("Nameboard"));
            nameboardGOE.transform.SetParent(nameboardCanvas);
            var    nameboardBehav = nameboardGOE.GetComponent <Nameboard>();
            var    uid            = EntityManager.GetComponentData <UID>(request.Owner);
            string name           = SceneMgr.Instance.GetNameByUID(uid.Value);
            nameboardBehav.Name = name;
            var isMainRole = RoleMgr.GetInstance().IsMainRoleEntity(request.Owner);
            nameboardBehav.CurColorStyle = isMainRole ? Nameboard.ColorStyle.Green : Nameboard.ColorStyle.Red;
            if (EntityManager.HasComponent <NameboardData>(request.Owner))
            {
                var nameboardData = EntityManager.GetComponentData <NameboardData>(request.Owner);
                nameboardData.UIEntity   = nameboardGOE.Entity;
                nameboardData.UIResState = NameboardData.ResState.Loaded;
                EntityManager.SetComponentData(request.Owner, nameboardData);
            }
        }
    }
Esempio n. 8
0
        public RoleInfoHandler()
        {
            m_roleinfoMgr  = new RoleInfoMgr();
            m_goodsListMgr = new GoodsListMgr();
            m_equiplistMgr = new EquipListMgr();

            m_roleMgr = new RoleMgr();
        }
Esempio n. 9
0
    protected override void OnUpdate()
    {
        //TODO:控制刷新或请求频率
        var requestArray = RequestGroup.ToComponentDataArray <RoleLooksNetRequest>(Allocator.TempJob);

        if (requestArray.Length == 0)
        {
            requestArray.Dispose();
            return;
        }

        var requestEntityArray = RequestGroup.ToEntityArray(Allocator.TempJob);

        // Copy requests as spawning will invalidate Group
        var requests = new RoleLooksNetRequest[requestArray.Length];

        for (var i = 0; i < requestArray.Length; i++)
        {
            requests[i] = requestArray[i];
            PostUpdateCommands.DestroyEntity(requestEntityArray[i]);
        }

        for (var i = 0; i < requests.Length; i++)
        {
            SprotoType.scene_get_role_look_info.request req = new SprotoType.scene_get_role_look_info.request();
            req.uid = requests[i].roleUid;
            Entity owner = requests[i].owner;
            if (!EntityManager.Exists(owner))
            {
                continue;
            }
            UnityMMO.NetMsgDispatcher.GetInstance().SendMessage <Protocol.scene_get_role_look_info>(req, (_) =>
            {
                SprotoType.scene_get_role_look_info.response rsp = _ as SprotoType.scene_get_role_look_info.response;
                // Debug.Log("rsp.result : "+rsp.result.ToString()+" owner:"+owner.ToString());
                if (rsp.result == UnityMMO.GameConst.NetResultOk)
                {
                    RoleMgr.GetInstance().SetName(req.uid, rsp.role_looks_info.name);
                    if (m_world.GetEntityManager().HasComponent <HealthStateData>(owner))
                    {
                        var hpData   = m_world.GetEntityManager().GetComponentData <HealthStateData>(owner);
                        hpData.CurHp = rsp.role_looks_info.hp;
                        hpData.MaxHp = rsp.role_looks_info.max_hp;
                        m_world.GetEntityManager().SetComponentData <HealthStateData>(owner, hpData);
                    }
                    bool hasTrans = m_world.GetEntityManager().HasComponent <Transform>(owner);
                    if (hasTrans)
                    {
                        var transform = m_world.GetEntityManager().GetComponentObject <Transform>(owner);
                        //因为是异步操作,等后端发送信息过来时PostUpdateCommands已经失效了,所以不能这么用
                        RoleLooksSpawnRequest.Create(m_world.GetEntityManager(), (int)rsp.role_looks_info.career, transform.localPosition, transform.localRotation, owner, (int)rsp.role_looks_info.body, (int)rsp.role_looks_info.hair);
                    }
                }
            });
        }
        requestEntityArray.Dispose();
        requestArray.Dispose();
    }
Esempio n. 10
0
        public RoleBase(String name, Form1 view, Model model, RoleMgr roleMgr, ChessType chessType)
        {
            Name        = name;
            View        = view;
            Model       = model;
            RoleMgr     = roleMgr;
            MyChessType = chessType;
            TurnCount   = 0;

            addCommand("RenewCommand", isAllowRenewCommand, onRenewCommand);
            addCommand("ReturnHomeCommand", isAllowReturnHomeCommand, onReturnHomeCommand);
        }
Esempio n. 11
0
    protected override void OnUpdate()
    {
        var requestArray  = Group.ToComponentDataArray <NameboardSpawnRequest>(Allocator.TempJob);
        var entityArray   = Group.ToEntityArray(Allocator.TempJob);
        var spawnRequests = new NameboardSpawnRequest[requestArray.Length];

        for (var i = 0; i < requestArray.Length; i++)
        {
            spawnRequests[i] = requestArray[i];
            PostUpdateCommands.DestroyEntity(entityArray[i]);
        }

        for (var i = 0; i < spawnRequests.Length; i++)
        {
            var request = spawnRequests[i];
            if (!EntityManager.Exists(request.Owner))
            {
                continue;
            }
            GameObjectEntity nameboardGOE = m_world.SpawnByGameObject <GameObjectEntity>(ResMgr.GetInstance().GetGameObject("Nameboard"));
            nameboardGOE.transform.SetParent(nameboardCanvas);
            nameboardGOE.transform.localScale = new Vector3(-1, 1, 1);
            var    nameboardBehav = nameboardGOE.GetComponent <Nameboard>();
            var    uid            = EntityManager.GetComponentData <UID>(request.Owner);
            string name           = SceneMgr.Instance.GetNameByUID(uid.Value);
            nameboardBehav.Name = name;
            var isMainRole = RoleMgr.GetInstance().IsMainRoleEntity(request.Owner);
            // Debug.Log("name : "+name+" isMainRole:"+isMainRole);
            nameboardBehav.CurColorStyle = isMainRole ? Nameboard.ColorStyle.Green : Nameboard.ColorStyle.Red;
            if (EntityManager.HasComponent <NameboardData>(request.Owner))
            {
                var nameboardData = EntityManager.GetComponentData <NameboardData>(request.Owner);
                nameboardData.UIEntity   = nameboardGOE.Entity;
                nameboardData.UIResState = NameboardData.ResState.Loaded;
                EntityManager.SetComponentData(request.Owner, nameboardData);
            }
            bool hasHPData = EntityManager.HasComponent <HealthStateData>(request.Owner);
            // Debug.Log("has Hp data "+hasHPData);
            if (hasHPData)
            {
                var hpData = EntityManager.GetComponentData <HealthStateData>(request.Owner);
                nameboardBehav.MaxHp = hpData.MaxHp;
                nameboardBehav.CurHp = hpData.CurHp;
                // nameboardBehav.UpdateBloodBar(hpData.CurHp, hpData.MaxHp);
            }

            var sceneObjType = EntityManager.GetComponentData <SceneObjectTypeData>(request.Owner);
            nameboardBehav.SetBloodVisible(sceneObjType.Value == SceneObjectType.Role || sceneObjType.Value == SceneObjectType.Monster);
        }
        requestArray.Dispose();
        entityArray.Dispose();
    }
Esempio n. 12
0
 private bool onChangeComputerPlayCommand(CommandBase command)
 {
     if (command is ChangeComputerPlayCommand)
     {
         RoleMgr.ChangeComputerToPlay();
         return(true);
     }
     else
     {
         Console.WriteLine("command is not ChangeComputerPlayCommand");
         return(false);
     }
 }
Esempio n. 13
0
 private bool onComputerNextCommand(CommandBase command)
 {
     if (command is ComputerNextCommand)
     {
         RoleMgr.ChangeNextRole();
         return(true);
     }
     else
     {
         Console.WriteLine("command is not ComputerNextCommand");
         return(false);
     }
 }
Esempio n. 14
0
        public RoleHandler()
        {
            m_mgr       = new RoleMgr();
            m_userMgr   = new UserLoginDataMgr();
            m_serverMgr = new ServerPropertyMgr();

            m_roleinfoMgr  = new RoleInfoMgr();
            m_goodsListMgr = new GoodsListMgr();
            m_equiplistMgr = new EquipListMgr();

            m_taskMgr  = new TaskDataMgr();
            m_skillMgr = new SkillDataMgr();
        }
Esempio n. 15
0
    // Called when the state of the playable is set to Play
    public override void OnBehaviourPlay(Playable playable, FrameData info)
    {
        var isMainRole = RoleMgr.GetInstance().IsMainRoleEntity(Owner);

        // Debug.Log("cast skill behav isMainRole :"+isMainRole.ToString());
        if (isMainRole)
        {
            var trans = EntityMgr.GetComponentObject <Transform>(Owner);
            if (trans != null)
            {
                SprotoType.scene_cast_skill.request req = new SprotoType.scene_cast_skill.request();
                req.skill_id     = SkillID;
                req.cur_pos_x    = (long)(trans.localPosition.x * GameConst.RealToLogic);
                req.cur_pos_y    = (long)(trans.localPosition.y * GameConst.RealToLogic);
                req.cur_pos_z    = (long)(trans.localPosition.z * GameConst.RealToLogic);
                req.target_pos_x = (long)(trans.localPosition.x * GameConst.RealToLogic);
                req.target_pos_y = (long)(trans.localPosition.y * GameConst.RealToLogic);
                req.target_pos_z = (long)(trans.localPosition.z * GameConst.RealToLogic);
                req.direction    = (long)(trans.eulerAngles.y * GameConst.RealToLogic);
                // Debug.Log("req.direction : "+req.direction+" skillID "+SkillID);
                NetMsgDispatcher.GetInstance().SendMessage <Protocol.scene_cast_skill>(req, delegate(Sproto.SprotoTypeBase result){
                    SprotoType.scene_cast_skill.response ack = result as SprotoType.scene_cast_skill.response;
                    // Debug.Log("ack : "+(ack!=null).ToString());
                    if (ack == null)
                    {
                        return;
                    }
                    Debug.Log("scene_cast_skill ack.result : " + ack.result);
                    if (ack.result == 1)
                    {
                        XLuaFramework.CSLuaBridge.GetInstance().CallLuaFuncStr(GlobalEvents.MessageShow, "技能冷却中...");
                        return;
                    }
                    SkillManager.GetInstance().SetSkillCD((int)ack.skill_id, ack.cd_end_time);
                    // // Debug.Log("playable : "+(Playable.Equals(playable, Playable.Null)).ToString());
                    // var graph = PlayableExtensions.GetGraph(playable);
                    // // Debug.Log("graph.IsDone() : "+graph.IsDone().ToString());
                    // if (!graph.IsDone())
                    // {
                    //     var playableNum = graph.GetRootPlayableCount();
                    //     // Debug.Log("playableNum : "+playableNum);
                    //     for (int i = 0; i < playableNum; i++)
                    //     {
                    //         var rootPlayable = graph.GetRootPlayable(i);
                    //         FindFlyWord(rootPlayable, ack.fight_event.defenders, 0);
                    //     }
                    // }
                });
            }
        }
    }
Esempio n. 16
0
    void Start()
    {
        roleMgr     = gameObject.AddComponent <RoleMgr>();
        obstacleMgr = gameObject.AddComponent <ObstacleMgr>();

        clientUdp = new ClientUdp();
        clientUdp.StartClientUdp();
        clientUdp.msg_battle_start    = Message_Battle_Start;
        clientUdp.msg_frame_operation = Message_Frame_Operation;
        clientUdp.msg_delta_frame     = Message_Delta_Frame_Data;

        isBattleStart = false;
        StartCoroutine(WaitInitData());
    }
Esempio n. 17
0
    protected override void OnUpdate()
    {
        EntityArray entities       = RoleGroup.GetEntityArray();
        var         roleStateArray = RoleGroup.GetComponentArray <RoleState>();
        var         mainRoleGOE    = RoleMgr.GetInstance().GetMainRole();
        float3      mainRolePos    = float3.zero;

        if (mainRoleGOE != null)
        {
            mainRolePos = m_world.GetEntityManager().GetComponentData <Position>(mainRoleGOE.Entity).Value;
        }
        for (int i = 0; i < roleStateArray.Length; i++)
        {
            var  roleState          = roleStateArray[i];
            var  entity             = entities[i];
            bool isNeedReqLooksInfo = false;
            bool isNeedHideLooks    = false;

            //其它玩家离主角近时就要请求该玩家的角色外观信息
            var   curPos   = m_world.GetEntityManager().GetComponentData <Position>(entity).Value;
            float distance = Vector3.Distance(curPos, mainRolePos);
            Debug.Log("distance : " + distance);
            if (!roleState.hasLooks)
            {
                isNeedReqLooksInfo = distance <= 400;
                // bool isMainRole = m_world.GetEntityManager().HasComponent(entity, typeof(UnityMMO.MainRoleTag));
                // if (isMainRole)
                // {
                //     isNeedReqLooksInfo = true;
                // }
                // else
                // {
                // //其它玩家离主角近时就要请求该玩家的角色外观信息
                // var curPos = m_world.GetEntityManager().GetComponentData<Position>(entity).Value;
                // float distance = Vector3.Distance(curPos, mainRolePos);
                // Debug.Log("distance : "+distance);
                // isNeedReqLooksInfo = distance <= 200;
                // }
            }
            else
            {
                isNeedHideLooks = distance >= 300;
            }
            if (isNeedReqLooksInfo)
            {
                roleState.hasLooks = true;
                RoleLooksNetRequest.Create(PostUpdateCommands, roleState.roleUid, entity);
            }
        }
    }
Esempio n. 18
0
    void Start()
    {
        SolaEngine engine = SolaEngine.getInstance();

        _roleMgr = (RoleMgr)engine.getMgr(typeof(RoleMgr));

        loginBtn.onClicked += _onBtnClicked;

        if (_roleMgr.isSigned())
        {
//			Application.LoadLevel (ScenesName.MAIN);
//			Invoke("_autoLogin",2);
//			engine.send(1);
            return;
        }
    }
Esempio n. 19
0
        public override void onMyTurn()
        {
            Random random = new Random();

            int x, y;

            do
            {
                x = random.Next(GameDef.board_cell_length);
                y = random.Next(GameDef.board_cell_length);
            } while (Model.GetBoardByCopy()[y][x] != ChessType.None);

            bool isPutSuccessful = PutChess(x, y);

            RoleMgr.ChangeNextRole();
        }
Esempio n. 20
0
    public override void OnPointerDown(PointerEventData eventData)
    {
        OnDrag(eventData);
        var       goe     = RoleMgr.GetInstance().GetMainRole();
        AutoFight fightAi = goe.GetComponent <UnityMMO.AutoFight>();

        if (fightAi != null)
        {
            fightAi.enabled = false;
        }
        var moveQuery = goe.GetComponent <UnityMMO.MoveQuery>();

        if (moveQuery != null)
        {
            moveQuery.StopFindWay();
        }
    }
Esempio n. 21
0
    protected override void OnUpdate()
    {
        var    entities       = RoleGroup.ToEntityArray(Allocator.TempJob);
        var    uidArray       = RoleGroup.ToComponentDataArray <UID>(Allocator.TempJob);
        var    looksInfoArray = RoleGroup.ToComponentDataArray <LooksInfo>(Allocator.TempJob);
        var    mainRoleGOE    = RoleMgr.GetInstance().GetMainRole();
        float3 mainRolePos    = float3.zero;

        if (mainRoleGOE != null)
        {
            mainRolePos = m_world.GetEntityManager().GetComponentObject <Transform>(mainRoleGOE.Entity).localPosition;
        }
        for (int i = 0; i < looksInfoArray.Length; i++)
        {
            var  uid                = uidArray[i];
            var  looksInfo          = looksInfoArray[i];
            var  entity             = entities[i];
            bool isNeedReqLooksInfo = false;
            bool isNeedHideLooks    = false;

            //其它玩家离主角近时就要请求该玩家的角色外观信息
            var   curPos   = m_world.GetEntityManager().GetComponentObject <Transform>(entity).localPosition;
            float distance = Vector3.Distance(curPos, mainRolePos);
            if (looksInfo.CurState == LooksInfo.State.None)
            {
                isNeedReqLooksInfo = distance <= 400;
            }
            else
            {
                isNeedHideLooks = distance >= 300;
            }
            // Debug.Log("isNeedReqLooksInfo : "+isNeedReqLooksInfo.ToString()+" looksInfo.CurState:"+looksInfo.CurState.ToString());
            if (isNeedReqLooksInfo)
            {
                looksInfo.CurState = LooksInfo.State.Loading;
                // looksInfoArray[i] = looksInfo;
                EntityManager.SetComponentData <LooksInfo>(entities[i], looksInfo);
                RoleLooksNetRequest.Create(PostUpdateCommands, uid.Value, entity);
            }
        }
        entities.Dispose();
        looksInfoArray.Dispose();
        uidArray.Dispose();
    }
Esempio n. 22
0
        private bool onPreviousActionCommand(CommandBase command)
        {
            Console.WriteLine("onPreviousActionCommand");

            if (command is PreviousActionCommand)
            {
                PreviousActionCommand previousActionCommand = command as PreviousActionCommand;

                if (previousActionCommand.IsEnemyAi)
                {
                    //judge has my chessType
                    if (Model.GetBoard().Any(x => x.Any(y => y == MyChessType)))
                    {
                        //todo hard code
                        Player.TotalTurn -= 2;
                        Model.PreviousAction();
                        Model.PreviousAction();
                        View.RemoveLastChess();
                        View.RemoveLastChess();
                        RoleMgr.PreviousPlayerByJudgeContainAI();
                    }
                    else
                    {
                        Console.WriteLine("Not exit my chess,cant regret");
                    }
                }
                else
                {
                    Player.TotalTurn--;
                    Model.PreviousAction();
                    View.RemoveLastChess();
                    RoleMgr.PreviousPlayerByJudge();
                }

                return(true);
            }
            else
            {
                Console.WriteLine("command is not PreviousActionCommand");
                return(false);
            }
        }
Esempio n. 23
0
        public async Task <IActionResult> CreateRole(ProjectRole role)
        {
            var roles = new AppRole
            {
                Name = role.RoleName,
            };

            var roleExist = await RoleMgr.RoleExistsAsync(role.RoleName);

            if (!roleExist)
            {
                var result = await RoleMgr.CreateAsync(roles);

                if (result.Succeeded)
                {
                    return(RedirectToAction("index", "Home"));
                }
            }
            return(View(role));
        }
Esempio n. 24
0
        public async Task <IActionResult> Create([Bind("Id,Name,Row,Col,RoleId")] Room room)
        {
            if (ModelState.IsValid)
            {
                Role role = new Role();
                int  idem = _context.Rooms.Count() + 1;
                room.Name = "Room " + idem;
                role.Name = "Manager " + room.Name;
                await RoleMgr.CreateAsync(role);

                room.RoleId = role.Id;
                _context.Add(room);
                await _context.SaveChangesAsync();

                Message = "Successfully create rooms";
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RoleId"] = new SelectList(_context.Staffs, "Id", "RoleId", room.Role.Name);
            return(View(room));
        }
Esempio n. 25
0
    protected override void OnUpdate()
    {
        EntityArray entities       = RoleGroup.GetEntityArray();
        var         roleStateArray = RoleGroup.GetComponentArray <RoleState>();
        var         looksInfoArray = RoleGroup.GetComponentDataArray <LooksInfo>();
        var         mainRoleGOE    = RoleMgr.GetInstance().GetMainRole();
        float3      mainRolePos    = float3.zero;

        if (mainRoleGOE != null)
        {
            mainRolePos = m_world.GetEntityManager().GetComponentObject <Transform>(mainRoleGOE.Entity).localPosition;
        }
        for (int i = 0; i < looksInfoArray.Length; i++)
        {
            var  roleState          = roleStateArray[i];
            var  looksInfo          = looksInfoArray[i];
            var  entity             = entities[i];
            bool isNeedReqLooksInfo = false;
            bool isNeedHideLooks    = false;

            //其它玩家离主角近时就要请求该玩家的角色外观信息
            var   curPos   = m_world.GetEntityManager().GetComponentObject <Transform>(entity).localPosition;
            float distance = Vector3.Distance(curPos, mainRolePos);
            if (looksInfo.CurState == LooksInfo.State.None)
            {
                isNeedReqLooksInfo = distance <= 400;
            }
            else
            {
                isNeedHideLooks = distance >= 300;
            }
            // Debug.Log("isNeedReqLooksInfo : "+isNeedReqLooksInfo.ToString()+" looksInfo.CurState:"+looksInfo.CurState.ToString());
            if (isNeedReqLooksInfo)
            {
                roleState.hasLooks = true;
                looksInfo.CurState = LooksInfo.State.Loading;
                looksInfoArray[i]  = looksInfo;
                RoleLooksNetRequest.Create(PostUpdateCommands, roleState.roleUid, entity);
            }
        }
    }
Esempio n. 26
0
        public override void onMyTurn()
        {
            base.onMyTurn();

            int bestScore = int.MinValue;
            int bestX     = -1;
            int bestY     = -1;

            if (TotalTurn == 0)
            {
                System.Console.WriteLine($"AI Turn 1");
                bool isPutSuccessful = PutChess(GameDef.board_cell_length / 2, GameDef.board_cell_length / 2);
                RoleMgr.ChangeNextRole();
            }
            else
            {
                for (int y = 0; y < GameDef.board_cell_length; y++)
                {
                    for (int x = 0; x < GameDef.board_cell_length; x++)
                    {
                        var board = Model.GetBoardByCopy();
                        if (board[y][x] == ChessType.None)
                        {
                            Model cloneModel = Model.Clone() as Model;

                            int score = MyEvaluation.GetScore(cloneModel, y, x, MyChessType);

                            if (score > bestScore)
                            {
                                bestScore = score;
                                bestX     = x;
                                bestY     = y;
                            }
                        }
                    }
                }

                bool isPutSuccessful = PutChess(bestX, bestY);
                RoleMgr.ChangeNextRole();
            }
        }
Esempio n. 27
0
    private void _updateRoleView()
    {
        _engine  = SolaEngine.getInstance();
        _roleMgr = (RoleMgr)_engine.getMgr(typeof(RoleMgr));

        roleNameText.text = _roleMgr.getRoleId();
        int roleLevel = _roleMgr.getRoleLevel();

        roleHpSlider.minValue = 0;
        int maxHp = roleLevel * 10 + 50;

        roleHpSlider.maxValue = maxHp;
        roleHpSlider.value    = 30;

        roleExpSlider.minValue = 0;
        int maxExp = _roleMgr.getRoleMaxExp();

        roleExpSlider.maxValue = maxExp;
        roleExpSlider.value    = maxExp / 3 * 2;

        heroAtkSlider.maxValue = 999;
        heroHpSlider.maxValue  = 999;
        heroSpdSlider.maxValue = 99;
    }
Esempio n. 28
0
 public void Init(Entity owner, EntityManager entityMgr)
 {
     Owner      = owner;
     EntityMgr  = entityMgr;
     isMainRole = RoleMgr.GetInstance().IsMainRoleEntity(Owner);
 }
Esempio n. 29
0
 public EasyComputerPlayer(String name, Form1 view, Model model, RoleMgr roleMgr, ChessType chessType) : base(name, view, model, roleMgr, chessType)
 {
 }
Esempio n. 30
0
        public Judge(String name, Form1 view, Model model, RoleMgr roleMgr, ChessType chessType) : base(name, view, model, roleMgr, chessType)
        {
            ConnectStrategy = new ConnectStrategy(model);

            addCommand("PreviousActionCommand", isAllowPreviousActionCommand, onPreviousActionCommand);
        }