Exemple #1
0
    public void AdjustMove(PlayerOperateCycleQueue ownerOperateRecords)
    {
        PlayerOperate curOptRec = m_playerOperate;

        for (int i = 0; i < ownerOperateRecords.Count; ++i)
        {
            m_playerOperate.Reset();
            var opRec = ownerOperateRecords[i];
            switch (opRec.optype)
            {
            case OperateType.OT_None:
                break;

            case OperateType.OT_StartRun:
                this.StartRun(opRec.isRight);
                break;

            case OperateType.OT_StopRun:
                this.StopRun();
                break;

            default:
                break;
            }
            this.MoveStep(Time.fixedDeltaTime);
        }
        m_playerOperate = curOptRec;
    }
Exemple #2
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="delaMove"></param>
    private void SendDir(Vector2 delaMove)
    {
        float dictance = 0;

        //if (GameController.Instance.TouchType == TouchType.Normal)
        //{
        //    dictance = Mathf.Min(Mathf.Max(0, xNormalDistance) * Screen.width, Mathf.Max(0, yNormalDistance) * Screen.height);
        //}
        //else if (GameController.Instance.TouchType == TouchType.Auto)
        //{
        //    dictance = Mathf.Min(Mathf.Max(0, xAutoDistance) * Screen.width, Mathf.Max(0, yAutoDistance) * Screen.height);
        //}
        if (Screen.height / Screen.width > 1334f / 750f)
        {
            dictance = Screen.width * moveDistance / 750f;
        }
        else
        {
            dictance = Screen.height * moveDistance / 1334f;
        }
        //if (log)
        //{
        //    Debug.Log(dictance + "  " + delaMove.x);
        //}

        PlayerOperate operate = PlayerOperate.None;

        if ((Mathf.Abs(delaMove.x) >= dictance || Mathf.Abs(delaMove.y) >= dictance))
        {
            if (Mathf.Abs(delaMove.x) > Mathf.Abs(delaMove.y))
            {
                if (delaMove.x > 0)
                {
                    operate = PlayerOperate.ToRight;
                }
                else
                {
                    operate = PlayerOperate.ToLeft;
                }
            }
            else
            {
                if (delaMove.y > 0)
                {
                    operate = PlayerOperate.ToUp;
                }
                else
                {
                    operate = PlayerOperate.ToDown;
                }
            }
        }

        if (curCall != null && operate != PlayerOperate.None)
        {
            finishTouch = true;
            curCall(operate);
        }
    }
Exemple #3
0
 /// <summary>
 /// 玩家操作回调
 /// </summary>
 /// <param name="playerOperate"></param>
 private void PlayOperate(PlayerOperate playerOperate)
 {
     if (!IsHasItemPlayAnimation())
     {
         switch (playerOperate)
         {
         case PlayerOperate.ToLeft:
         case PlayerOperate.ToRight:
         case PlayerOperate.ToUp:
         case PlayerOperate.ToDown:
             mapData = playCtrl.Move(playerOperate);
             RefreshMap(mapData.gridDatas);
             break;
         }
     }
 }
Exemple #4
0
    private int attack;     //0未结算,1已结算

    private void Awake()
    {
        playerState = new PlayerState();
        playerOper  = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerOperate>();

        skills = new Skills();

        p1Hp = GameObject.FindGameObjectWithTag("P1hp").GetComponent <Text>();
        p1Mp = GameObject.FindGameObjectWithTag("P1mp").GetComponent <Text>();
        p2Hp = GameObject.FindGameObjectWithTag("P2hp").GetComponent <Text>();
        p2Mp = GameObject.FindGameObjectWithTag("P2mp").GetComponent <Text>();

        timer = GameObject.FindGameObjectWithTag("Timer").GetComponent <Text>();

        operPanel = GameObject.FindGameObjectWithTag("Operate");
    }
Exemple #5
0
    /// <summary>
    /// 移动地图
    /// </summary>
    /// <param name="md"></param>
    /// <returns></returns>
    public MapData Move(PlayerOperate md)
    {
        if (!isPause && state == GameState.Play)
        {
            MapData mapData = new MapData();
            if (mapDatas == null)
            {
                mapDatas = new List <MapData>();
            }

            mapData = MergeMove(md);
            if (mapData != curMapData)
            {
                RecoradOperate(mapData);
                InsertANumber();
                CheckEndState();
            }
            return(curMapData.Clone());
        }
        else
        {
            return(curMapData.Clone());
        }
    }
Exemple #6
0
    /// <summary>
    /// 合并和移动地图
    /// </summary>
    /// <returns></returns>
    private MapData MergeMove(PlayerOperate MoveDirection)
    {
        List <int> mergeIDs = new List <int>();
        bool       isMerge  = false;
        MapData    ret      = new MapData();

        ret.Score             = curMapData.Score;
        ret.lastMoveDirection = MoveDirection;
        Dictionary <int, Dictionary <int, GridData> > allMapData = new Dictionary <int, Dictionary <int, GridData> >();

        for (int i = 0; i < curMapData.gridDatas.Count; i++)
        {
            var item = curMapData.gridDatas[i].Clone();
            item.MergeID      = 0;
            item.GridType     = GridType.Old;
            item.FromPosition = new Vector2Int(0, 0);
            if (!allMapData.ContainsKey(item.Position.x))
            {
                allMapData.Add(item.Position.x, new Dictionary <int, GridData>());
            }
            allMapData[item.Position.x][item.Position.y] = item;
        }
        bool isMove = false;

        //滑动的时候先合并在进行移动
        switch (MoveDirection)
        {
        case PlayerOperate.ToLeft:
            //合并
            for (int y = 1; y <= mapSize; y++)
            {
                for (int x = 1; x <= mapSize; x++)
                {
                    for (int targetX = x + 1; targetX <= mapSize; targetX++)
                    {
                        if (allMapData.ContainsKey(x) && allMapData[x].ContainsKey(y) && allMapData[x][y] != null &&
                            (allMapData.ContainsKey(targetX) && allMapData[targetX].ContainsKey(y) && allMapData[targetX][y] != null))
                        {
                            if (allMapData[x][y].Ladder == allMapData[targetX][y].Ladder &&
                                allMapData[x][y].Ladder > 0)
                            {
                                AddScore(ret, allMapData[x][y].Ladder);
                                allMapData[x][y].Ladder  = AddLevel(allMapData[x][y].Ladder);
                                allMapData[x][y].MergeID = allMapData[targetX][y].ID;
                                mergeIDs.Add(allMapData[targetX][y].ID);
                                allMapData[targetX][y] = null;
                                isMerge = true;
                                break;
                            }
                        }
                        if (allMapData.ContainsKey(targetX) && allMapData[targetX].ContainsKey(y) && allMapData[targetX][y] != null)
                        {
                            break;
                        }
                    }
                }
            }
            //移动
            for (int y = 1; y <= mapSize; y++)
            {
                for (int x = 1; x <= mapSize; x++)
                {
                    for (int tempx = 1; tempx <= x; tempx++)
                    {
                        if (allMapData.ContainsKey(x) && allMapData[x].ContainsKey(y) && allMapData[x][y] != null &&
                            (!allMapData.ContainsKey(tempx) || !allMapData[tempx].ContainsKey(y) || allMapData[tempx][y] == null))
                        {
                            if (!allMapData.ContainsKey(tempx))
                            {
                                allMapData.Add(tempx, new Dictionary <int, GridData>());
                            }
                            isMove = true;
                            allMapData[tempx][y]              = allMapData[x][y];
                            allMapData[tempx][y].Position     = new Vector2Int(tempx, y);
                            allMapData[tempx][y].FromPosition = allMapData[tempx][y].Position;
                            allMapData[x][y] = null;
                            break;
                        }
                    }
                }
            }
            if (mergeIDs.Count == 0 && !isMove)
            {
                ret = curMapData;
            }
            break;

        case PlayerOperate.ToRight:
            //合并
            for (int y = 1; y <= mapSize; y++)
            {
                for (int x = mapSize; x > 0; x--)
                {
                    for (int targetX = x - 1; targetX >= 0; targetX--)
                    {
                        if (allMapData.ContainsKey(x) && allMapData[x].ContainsKey(y) && allMapData[x][y] != null &&
                            (allMapData.ContainsKey(targetX) && allMapData[targetX].ContainsKey(y) && allMapData[targetX][y] != null))
                        {
                            if (allMapData[x][y].Ladder == allMapData[targetX][y].Ladder &&
                                allMapData[x][y].Ladder > 0)
                            {
                                AddScore(ret, allMapData[x][y].Ladder);
                                allMapData[x][y].Ladder  = AddLevel(allMapData[x][y].Ladder);
                                allMapData[x][y].MergeID = allMapData[targetX][y].ID;
                                mergeIDs.Add(allMapData[targetX][y].ID);
                                allMapData[targetX][y] = null;
                                isMerge = true;
                                break;
                            }
                        }
                        if (allMapData.ContainsKey(targetX) && allMapData[targetX].ContainsKey(y) && allMapData[targetX][y] != null)
                        {
                            break;
                        }
                    }
                }
            }
            //移动
            for (int y = 1; y <= mapSize; y++)
            {
                for (int x = mapSize; x >= 1; x--)
                {
                    for (int tempx = mapSize; tempx > x; tempx--)
                    {
                        if (allMapData.ContainsKey(x) && allMapData[x].ContainsKey(y) && allMapData[x][y] != null &&
                            (!allMapData.ContainsKey(tempx) || !allMapData[tempx].ContainsKey(y) || allMapData[tempx][y] == null))
                        {
                            if (!allMapData.ContainsKey(tempx))
                            {
                                allMapData.Add(tempx, new Dictionary <int, GridData>());
                            }
                            isMove = true;
                            allMapData[tempx][y]              = allMapData[x][y];
                            allMapData[tempx][y].Position     = new Vector2Int(tempx, y);
                            allMapData[tempx][y].FromPosition = allMapData[tempx][y].Position;
                            allMapData[x][y] = null;
                            break;
                        }
                    }
                }
            }
            if (mergeIDs.Count == 0 && !isMove)
            {
                ret = curMapData;
            }
            break;

        case PlayerOperate.ToUp:
            //合并
            for (int x = 1; x <= mapSize; x++)
            {
                for (int y = mapSize; y >= 1; y--)
                {
                    for (int targetY = y - 1; targetY >= 1; targetY--)
                    {
                        if (allMapData.ContainsKey(x) && allMapData[x].ContainsKey(y) && allMapData[x][y] != null &&
                            (allMapData.ContainsKey(x) && allMapData[x].ContainsKey(targetY) && allMapData[x][targetY] != null))
                        {
                            if (allMapData[x][y].Ladder == allMapData[x][targetY].Ladder &&
                                allMapData[x][y].Ladder > 0)
                            {
                                AddScore(ret, allMapData[x][y].Ladder);
                                allMapData[x][y].Ladder  = AddLevel(allMapData[x][y].Ladder);
                                allMapData[x][y].MergeID = allMapData[x][targetY].ID;
                                mergeIDs.Add(allMapData[x][targetY].ID);
                                //mergeIDs.Add(allMapData[x][y].ID);
                                allMapData[x][targetY] = null;
                                isMerge = true;
                                break;
                            }
                        }
                        if (allMapData.ContainsKey(x) && allMapData[x].ContainsKey(targetY) && allMapData[x][targetY] != null)
                        {
                            break;
                        }
                    }
                }
            }
            //移动
            for (int x = 1; x <= mapSize; x++)
            {
                for (int y = mapSize; y >= 1; y--)
                {
                    for (int tempY = mapSize; tempY > y; tempY--)
                    {
                        if (allMapData.ContainsKey(x) && allMapData[x].ContainsKey(y) && allMapData[x][y] != null &&
                            (!allMapData.ContainsKey(x) || !allMapData[x].ContainsKey(tempY) || allMapData[x][tempY] == null))
                        {
                            if (!allMapData.ContainsKey(x))
                            {
                                allMapData.Add(x, new Dictionary <int, GridData>());
                            }
                            isMove = true;
                            allMapData[x][tempY]              = allMapData[x][y];
                            allMapData[x][tempY].Position     = new Vector2Int(x, tempY);
                            allMapData[x][tempY].FromPosition = allMapData[x][y].Position;
                            allMapData[x][y] = null;
                            break;
                        }
                    }
                }
            }
            if (mergeIDs.Count == 0 && !isMove)
            {
                ret = curMapData;
            }
            break;

        case PlayerOperate.ToDown:
            //合并
            for (int x = 1; x <= mapSize; x++)
            {
                for (int y = 1; y <= mapSize; y++)
                {
                    for (int targetY = y + 1; targetY <= mapSize; targetY++)
                    {
                        if (allMapData.ContainsKey(x) && allMapData[x].ContainsKey(y) && allMapData[x][y] != null &&
                            (allMapData.ContainsKey(x) && allMapData[x].ContainsKey(targetY) && allMapData[x][targetY] != null))
                        {
                            if (allMapData[x][y].Ladder == allMapData[x][targetY].Ladder &&
                                allMapData[x][y].Ladder > 0)
                            {
                                AddScore(ret, allMapData[x][y].Ladder);
                                allMapData[x][y].Ladder  = AddLevel(allMapData[x][y].Ladder);
                                allMapData[x][y].MergeID = allMapData[x][targetY].ID;
                                mergeIDs.Add(allMapData[x][targetY].ID);
                                allMapData[x][targetY] = null;
                                isMerge = true;
                                break;
                            }
                            if (allMapData.ContainsKey(x) && allMapData[x].ContainsKey(targetY) && allMapData[x][targetY] != null)
                            {
                                break;
                            }
                        }
                    }
                }
            }
            //移动
            for (int x = 1; x <= mapSize; x++)
            {
                for (int y = 1; y <= mapSize; y++)
                {
                    for (int tempY = 1; tempY < y; tempY++)
                    {
                        if (allMapData.ContainsKey(x) && allMapData[x].ContainsKey(y) && allMapData[x][y] != null &&
                            (!allMapData.ContainsKey(x) || !allMapData[x].ContainsKey(tempY) || allMapData[x][tempY] == null))
                        {
                            if (!allMapData.ContainsKey(x))
                            {
                                allMapData.Add(x, new Dictionary <int, GridData>());
                            }
                            isMove = true;
                            allMapData[x][tempY]              = allMapData[x][y];
                            allMapData[x][tempY].Position     = new Vector2Int(x, tempY);
                            allMapData[x][tempY].FromPosition = allMapData[x][y].Position;
                            allMapData[x][y] = null;
                            break;
                        }
                    }
                }
            }
            if (mergeIDs.Count == 0 && !isMove)
            {
                ret = curMapData;
            }
            break;

        case PlayerOperate.None:
            ret = curMapData;
            break;
        }
        if (ret != curMapData)
        {
            ret.gridDatas = new List <GridData>();
            foreach (var itemDic in allMapData)
            {
                foreach (var item in itemDic.Value)
                {
                    if (item.Value != null)
                    {
                        ret.gridDatas.Add(item.Value);
                    }
                }
            }
        }
        if (isMerge)
        {
            AudioController.Instance.PlaySound(AudioType.merge);
        }
        else if (isMove)
        {
            AudioController.Instance.PlaySound(AudioType.move);
        }

        return(ret);
    }
Exemple #7
0
 public void SendServerMove(Vector3 curPos, PlayerOperate playerOperate)
 {
     m_ownerOperateRecords.Push(playerOperate);
     CmdServerMove(ActorRun.MoveSeq, curPos, playerOperate.isRun, playerOperate.isRight);
 }