コード例 #1
0
        // 受け取った入力を処理+結果をクライアントに送信
        // dotダメージや建造物の効果などはEndPhaseの最後で発動する
        private void EndPhase()
        {
            if (!PhotonNetwork.IsMasterClient)
            {
                return;
            }
            Debug.Log("EndPhase");

            GameState = GameState.TurnEnd;
            Ready1    = false;
            Ready2    = false;

            // TODO: 入力を元にactionを処理、イベント生成
            ActionEventToClient actionEventToClient = BattleLogic.ProcessActionEvents(actionEvent1, actionEvent2);

            // イベント送信&同期
            object[] args1 = new object[] { "ActionEventToClient", JsonUtility.ToJson(actionEventToClient) };
            object[] args2 = new object[] { "ActionEventToClient", JsonUtility.ToJson(actionEventToClient) };
            MasterPlayer.GetComponent <PhotonView> ().RPC("RecieveEvent", RpcTarget.AllViaServer, args1);
            GuestPlayer.GetComponent <PhotonView> ().RPC("RecieveEvent", RpcTarget.AllViaServer, args2);
            SyncBoardToClients();
        }
コード例 #2
0
        // プレイヤーの行動を処理してクライアントへエフェクトの表示等をさせる命令を返す
        public ActionEventToClient ProcessActionEvents(ActionEvent unitAction1, ActionEvent unitAction2)
        {
            if (unitAction1.UnitActions.Length == 0 && unitAction2.UnitActions.Length == 0)
            {
                return(new ActionEventToClient());
            }
            ActionEventToClient       actionEventToClient = new ActionEventToClient();
            List <UnitActionToClient> unitActionsToClient = new List <UnitActionToClient> ();

            // Agility順に各ユニットの行動をソート
            List <UnitAction> concatUnitActions = new List <UnitAction> ();

            if (unitAction1 != null)
            {
                for (int i = 0; i < unitAction1.UnitActions.Length; i++)
                {
                    concatUnitActions.Add(unitAction1.UnitActions[i]);
                }
            }
            if (unitAction2 != null)
            {
                for (int i = 0; i < unitAction2.UnitActions.Length; i++)
                {
                    concatUnitActions.Add(unitAction2.UnitActions[i]);
                }
            }
            concatUnitActions.Sort((a, b) => b.Agility - a.Agility);

            // 各行動を処理
            for (int i = 0; i < concatUnitActions.Count; i++)
            {
                // skillTypeで分岐
                if (concatUnitActions[i].ActionNo == 0)
                {
                    // Move
                    unitActionsToClient.Add(Move(concatUnitActions[i].Owner, concatUnitActions[i].Invoker, (concatUnitActions[i].TargetPositionX, concatUnitActions[i].TargetPositionY)));
                }
                else if (concatUnitActions[i].ActionNo <= -1)
                {
                    // 通常攻撃
                    Debug.Log("normal attack");
                }
                else if (GetUnitList(concatUnitActions[i].Owner) [concatUnitActions[i].Invoker].SkillList[concatUnitActions[i].ActionNo].SkillType == SkillType.Attack)
                {
                    // Attack todo
                }
                else
                {
                    // 空のアクション
                    Debug.Log("None");
                    unitActionsToClient.Add(None());
                }
            }

            // ActionEventToClientを返す
            Debug.Log(unitActionsToClient.Count);
            actionEventToClient.UnitActions = new UnitActionToClient[unitActionsToClient.Count];
            for (int i = 0; i < unitActionsToClient.Count; i++)
            {
                actionEventToClient.UnitActions[i] = unitActionsToClient[i];
            }

            return(actionEventToClient);
        }