Пример #1
0
    //길찾기 과정
    void GetDirections()
    {
        if (GameData.bIsClick == true)   //타일 입력이 확인되면 길찾기 시작
        {
            for (int i = TileList.Count; i > 0; --i)
            {
                TileList[i - 1].GetComponent <Tiles>().bIsOpen  = false;
                TileList[i - 1].GetComponent <Tiles>().bIsClose = false;
                TileList[i - 1].GetComponent <Tiles>().g        = 0;
                TileList[i - 1].GetComponent <Tiles>().f        = 0;
                TileList[i - 1].GetComponent <Tiles>().h        = 0;
            }

            m_pPlayerMove = GameData.gNowPlayer.GetComponent <PlayerAct>();

            GameData.tStartTile.X = m_pPlayerMove.X;
            GameData.tStartTile.Y = m_pPlayerMove.Y;
            GameData.tStartTile.Z = m_pPlayerMove.Z;

            //초기화
            m_bIsGoal = false;
            BestList.Clear();
            OpenList.Clear();
            CloseList.Clear();
            m_tFinal = GameData.tFinalTile;
            int startIdx = Getidx(m_tStart);
            m_bIsFindRange = false;

            AddOpenList(startIdx);
            Loop();
            Result();
        }
    }
Пример #2
0
    private void Move(PlayerAct playerAct)
    {
        GameSituation gameSituation = chessGame.MakeMove(playerAct.From, playerAct.To);

        whitePlayer.SetGameSituation(gameSituation);
        blackPlayer.SetGameSituation(gameSituation);
    }
Пример #3
0
 private void OnPlayerAct(PlayerAct playerAct)
 {
     if (playerAct.Act == PlayerAct.ActType.Exit)
     {
         return;
     }
     m_ActEvent(playerAct);
 }
Пример #4
0
 private void Start()
 {
     player    = GetComponent <PlayerAct>();
     p_sCamera = FindObjectOfType <SimpleCameraFreeLook>();
     if (p_sCamera == null)
     {
         Debug.LogErrorFormat(this, "Camera missing.");
     }
     p_cameraTrans = p_sCamera.transform;
 }
Пример #5
0
 public void SetPlayerAct(PlayerAct playerAct)
 {
     if (playerAct.Act == PlayerAct.ActType.Move)
     {
         Move(playerAct);
     }
     else if (playerAct.Act == PlayerAct.ActType.Exit)
     {
         Exit(playerAct);
     }
 }
Пример #6
0
    private void MoveIsMade(Cell from, Cell to)
    {
        PlayerAct playerAct = new PlayerAct
        {
            Act  = PlayerAct.ActType.Move,
            From = from,
            To   = to
        };

        ActEvent(playerAct);
    }
Пример #7
0
 void Start()
 {
     mPlayerStatus = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerStatus>();
     mPlayerAct    = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerAct>();
     mIcon         = UITool.FindChild <Image>(gameObject, "Image");
     mIcon.gameObject.SetActive(false);
     MaskIcon            = UITool.FindChild <Image>(gameObject, "Mask");
     MaskIcon.fillAmount = 0;
     CoolTime            = UITool.FindChild <Text>(gameObject, "CoolTime");
     CoolTime.enabled    = false;
 }
Пример #8
0
 // Update is called once per frame
 void Update()
 {
     if (playerActedEvent != null)
     {
         if (this.playerAct != null)
         {
             PlayerAct playerAct = this.playerAct;
             this.playerAct = null;
             playerActedEvent(playerAct);
         }
     }
 }
Пример #9
0
    private void OnEngineMoved(Cell from, Cell to)
    {
        PlayerAct playerAct = new PlayerAct()
        {
            Act         = PlayerAct.ActType.Move,
            From        = from,
            To          = to,
            PlayerColor = playerColor
        };
        UCIThreadAdapter uciThreadAdapter = UCIThreadAdapter.GetInstance();

        uciThreadAdapter.SetPlayerAct(playerAct);
    }
Пример #10
0
    public void ExitButtonPressed()
    {
        if (endGame)
        {
            SceneManager.LoadScene(0);
            return;
        }
        PlayerAct playerAct = new PlayerAct()
        {
            Act = PlayerAct.ActType.Exit
        };

        ActEvent(playerAct);
        SceneManager.LoadScene(0);
    }
Пример #11
0
    public static PlayerAct Deserealize(SerializedPlayerAct serialized)
    {
        PlayerAct playerAct = new PlayerAct
        {
            Act         = (PlayerAct.ActType)serialized.act,
            PlayerColor = (PlayerColor)serialized.playerColor
        };

        if (playerAct.Act != PlayerAct.ActType.Move)
        {
            return(playerAct);
        }
        playerAct.From = new Cell(serialized.fromVertical, serialized.fromHorizontal);
        playerAct.To   = new Cell(serialized.toVertical, serialized.toHorizontal);
        return(playerAct);
    }
Пример #12
0
    //发送
    public void SetStatusFlag(int userID, UserAction act, params List <int>[] arg)
    {
        Debug.Log("用户:" + userID + "-" + act.ToString() + "开始");
        //托管拦截
        if (players[userID].ID < 0 || players[userID].TrusteeFlag || players[userID].TingFlag)
        {
            switch (act)
            {
            case UserAction.get_card:
                control.SetStatusFlag(userID, act, arg);
                if (arg[1].Count > 1)
                {
                    int n = UnityEngine.Random.Range(0, arg[1].Count);
                    //随机获取操作状态
                    gameTip = (PlayerAct)arg[1][n];
                }
                else
                {
                    gameTip = PlayerAct.empty;
                }
                break;

            //arg[0]被吃玩家id arg[1]...arg[n]吃牌组合
            case UserAction.chi_card_flag:
            case UserAction.peng_card_flag:
            case UserAction.gang_flag:
                exebuff = arg[1];
                EndStatusFlag(userID, act, exebuff);
                break;

            case UserAction.chi_hu_flag:
                EndStatusFlag(userID, UserAction.hu);
                break;

            default:
                control.SetStatusFlag(userID, act, arg);
                break;
            }
        }
        else
        {
            //发送
            control.SetStatusFlag(userID, act, arg);
        }
    }
Пример #13
0
    public static SerializedPlayerAct Serialize(PlayerAct playerAct)
    {
        SerializedPlayerAct result = new SerializedPlayerAct
        {
            act         = (int)playerAct.Act,
            playerColor = (int)playerAct.PlayerColor
        };

        if (playerAct.Act != PlayerAct.ActType.Move)
        {
            return(result);
        }
        result.fromVertical   = playerAct.From.Vertical;
        result.fromHorizontal = playerAct.From.Horizontal;
        result.toVertical     = playerAct.To.Vertical;
        result.toHorizontal   = playerAct.To.Horizontal;

        return(result);
    }
Пример #14
0
    private void Exit(PlayerAct playerAct)
    {
        IPlayer player;

        if (playerAct.PlayerColor == PlayerColor.White)
        {
            player = blackPlayer;
        }
        else
        {
            player = whitePlayer;
        }
        GameSituation gameSituation = new GameSituation
        {
            GameStatus = GameStatus.OpponentExits
        };

        player.SetGameSituation(gameSituation);
    }
Пример #15
0
    private void Start()
    {
        EventManager.Instance.AddListener(EVENT_TYPE.FALL_OUT_RANGE, this);
        EventManager.Instance.AddListener(EVENT_TYPE.GET_KEY, this);

        SceneManager.sceneLoaded   += OnSceneLoaded;
        SceneManager.sceneUnloaded += OnSceneUnloaded;

        p_player     = GetComponentInChildren <PlayerAct>();
        p_controller = GetComponentInChildren <Controller>();
        p_camera     = GetComponentInChildren <SimpleCameraFreeLook>();
        PlayerTrans  = p_player.transform;

        var gi = GlobalHub.Instance;

        ChangeScene(gi.PlayerScene, gi.PlayerPos, gi.PlayerForward);

        StartCoroutine(SetCameraBack());  // 读档后稳定镜头
    }
Пример #16
0
    //이동범위를 보여줌
    void SetMoveRange()
    {
        if (GameData.iNowState == 4)
        {
            if (!m_bChInit)
            {
                return;
            }

            //초기화
            m_gPlayer       = GameData.gNowPlayer;
            m_pPlayerMove   = m_gPlayer.GetComponent <PlayerAct>();
            m_iMaxMoveRange = m_gPlayer.GetComponent <Status>().iMovingRange;
            m_iPlayerJump   = GameData.gNowPlayer.GetComponent <Status>().iJump;
            m_MoveOpen.Clear();
            m_MoveClose.Clear();
            GameData.tStartTile.X = m_pPlayerMove.X;
            GameData.tStartTile.Y = m_pPlayerMove.Y;
            GameData.tStartTile.Z = m_pPlayerMove.Z;
            m_tStart = GameData.tStartTile;
            m_iNowZ  = m_pPlayerMove.Z;
            m_MoveOpen.Clear();
            int idx = Getidx(m_tStart);
            m_MoveOpen.Add(idx);
            m_bIsFindRange = true;
            for (int i = TileList.Count; i > 0; --i)
            {
                TileList[i - 1].GetComponent <Tiles>().bIsOpen     = false;
                TileList[i - 1].GetComponent <Tiles>().bIsClose    = false;
                TileList[i - 1].GetComponent <Tiles>().g           = 0;
                TileList[i - 1].GetComponent <Tiles>().gIsOnPlayer = null;
            }

            while (true)
            {
                if (m_MoveOpen.Count == 0)
                {
                    break;
                }
                int min = int.MaxValue;
                for (int i = 0; i < m_MoveOpen.Count; i++)
                {
                    Tiles tTiles = TileList[m_MoveOpen[i]].GetComponent <Tiles>();
                    if (min > tTiles.g)
                    {
                        min = TileList[m_MoveOpen[i]].GetComponent <Tiles>().g;
                        idx = i;
                    }
                }

                idx = m_MoveOpen[idx];

                int Left  = FindgTile(Tiles.Tiledir.left, idx);
                int Right = FindgTile(Tiles.Tiledir.right, idx);
                int Up    = FindgTile(Tiles.Tiledir.up, idx);
                int Down  = FindgTile(Tiles.Tiledir.down, idx);

                TileInit(idx, Left, Tiles.Tiledir.left);
                TileInit(idx, Right, Tiles.Tiledir.right);
                TileInit(idx, Up, Tiles.Tiledir.up);
                TileInit(idx, Down, Tiles.Tiledir.down);

                Addm_MoveClose(idx);
            }

            m_bIsFindRange = false;
            m_bChInit      = false;
            m_bIsFindRange = false;
        }

        else
        {
            for (int i = 0; i < TileList.Count; i++)
            {
                TileList[i].GetComponent <Tiles>().SetMoveRange(false);
            }
            m_bChInit = true;
        }
    }
Пример #17
0
 private void OnPlayerAct(PlayerAct playerAct)
 {
     PlayerActedEvent(playerAct);
 }
Пример #18
0
 private void OnPlayerMoved(PlayerAct playerAct)
 {
     clientManager.Block(true, PlayerColor.White);
     clientManager.Block(true, PlayerColor.Black);
     PlayerActedEvent(playerAct);
 }
Пример #19
0
 private void PlayerActed(PlayerAct playerAct)
 {
     playerAct.PlayerColor = playerColor;
     CmdAct(SerializedPlayerAct.Serialize(playerAct));
 }
Пример #20
0
    private void CmdAct(SerializedPlayerAct serializedPlayerAct)
    {
        PlayerAct playerAct = SerializedPlayerAct.Deserealize(serializedPlayerAct);

        PlayerActedEvent(playerAct);
    }
Пример #21
0
 void Awake()
 {
     if(_instance == null)
     {
         _instance = this;
     }
     else
     {
         if(this != _instance)
             Destroy(this.gameObject);
     }
 }
Пример #22
0
 public void SetPlayerAct(PlayerAct playerAct)
 {
     this.playerAct = playerAct;
 }