Exemple #1
0
        private eMoveType realPlayerMove()
        {
            // Get the right coin according to the source coordinate.
            Coin coin =
                CurrentPlayer.GetCoinByCoordinate(LastCoordinate);

            eMoveType moveType =
                m_Checkers.MoveCoin(coin, TargetCoordinate);

            // If the source and target coordinates are valid make move.
            if (moveType.Equals(eMoveType.Step) ||
                moveType.Equals(eMoveType.Eat))
            {
                // If this player doesn't have an eating possibility,
                // choose available moove and then switch turns.
                if (moveType.Equals(eMoveType.Step) ||
                    (!m_Checkers.HasEatingMoves(m_Checkers.GetCoinOwner(coin)) &&
                     moveType.Equals(eMoveType.Eat)))
                {
                    // Switch the turn flags of the players.
                    m_Checkers.SwitchTurnFlags();
                }
            }

            return(moveType);
        }
Exemple #2
0
        private eMoveType computerMove(Computer i_Computer)
        {
            Coin randomCoin = i_Computer.ChooseRandomCoin();

            SourceCoordinate = randomCoin.Coordinates;
            TargetCoordinate = i_Computer.ChooseRandomCoordinate(randomCoin);


            eMoveType moveType =
                m_Checkers.MoveCoin(randomCoin, TargetCoordinate);

            // If the source and the target coordinates are valid make move.
            if (moveType.Equals(eMoveType.Step) || moveType.Equals(eMoveType.Eat))
            {
                // If this player doesn't have an eating possibility,
                // choose available move and then switch turns.
                if (moveType.Equals(eMoveType.Step) ||
                    (!m_Checkers.HasEatingMoves(i_Computer) &&
                     moveType.Equals(eMoveType.Eat)))
                {
                    m_Checkers.SwitchTurnFlags();
                }
            }
            return(moveType);
        }
Exemple #3
0
    /// <summary>
    /// 设置滑动后item位置
    /// </summary>
    /// <param name="index"></param>
    /// <param name="movetype"></param>
    /// <param name="obj">需要改变位置的item</param>
    /// <param name="trans">参照item,向上或向左滑动为当前mMinIndex位置的item,向下或向右滑动为当前mMaxIndex位置item</param>
    private void SetMoveItemPos(int index, eMoveType movetype, GameObject obj, Transform trans)
    {
        float posx = 0;
        float posy = 0;

        if (movetype == eMoveType.LeftAndUp)
        {
            if (mIsHorizontal)
            {
                posx = trans.localPosition.x + CellWidth;
                posy = mCorrectPos.y - CellHeight / 2 - index * CellHeight - Offeset.y;
            }
            else
            {
                posx = mCorrectPos.x + CellWidth / 2 + index * CellWidth + Offeset.x;
                posy = trans.localPosition.y - CellHeight;
            }
        }
        else if (movetype == eMoveType.RightAndDown)
        {
            if (mIsHorizontal)
            {
                posx = trans.localPosition.x - CellWidth;
                posy = mCorrectPos.y - CellHeight / 2 - index * CellHeight - Offeset.y;
            }
            else
            {
                posx = mCorrectPos.x + CellWidth / 2 + index * CellWidth + Offeset.x;
                posy = trans.localPosition.y + CellHeight;
            }
        }
        obj.transform.localPosition = new Vector3(posx, posy, 0);
    }
Exemple #4
0
 public LegalMoves(int i_FromSpotRow, int i_FromSpotColumn, int i_ToSpotRow, int i_ToSpotColumn, eMoveType i_KindOfMove)
 {
     r_FromSpotRow    = i_FromSpotRow;
     r_FromSpotColumn = i_FromSpotColumn;
     r_ToSpotRow      = i_ToSpotRow;
     r_ToSpotColumn   = i_ToSpotColumn;
     r_KindOfMove     = i_KindOfMove;
 }
Exemple #5
0
 public PlayerMove(string i_FromSlotKey, string i_ToSlotKey, string i_SlotKeyToEat, eMoveType i_Type = eMoveType.NoEat)
 {
     r_FromSlotKey  = i_FromSlotKey;
     r_ToSlotKey    = i_ToSlotKey;
     r_SlotKeyToEat = i_SlotKeyToEat;
     r_Type         = i_Type;
     r_Value        = getValueType(i_Type);
 }
Exemple #6
0
 public Move(Position i_Begin, Position i_End, ePlayerPosition i_Player, eMoveType i_MoveType)
 {
     // New move constructor
     r_Begin  = i_Begin;
     r_End    = i_End;
     m_Player = i_Player;
     m_Type   = i_MoveType;
 }
Exemple #7
0
 private void SetMoveType(eMoveType moveType)
 {
     if (m_moveType != moveType)
     {
         m_moveType = moveType;
         string stateName = moveType == eMoveType.Idle ? "idle_001" : "run_001";
         m_animator.CrossFade(stateName, 0.1f);
     }
 }
Exemple #8
0
        /// <summary>
        /// This method moves the given coin to the desired coordinate.
        /// If the move is invalid, the method will not change any coins location.
        /// </summary>
        /// <param name="i_Coin"></param>
        /// <param name="i_Target"></param>
        /// <returns>Type of move executed (Step, Eat, None)</returns>
        public eMoveType MoveCoin(Coin i_Coin, Coordinate i_Target)
        {
            eMoveType moveType = eMoveType.None;

            if (i_Coin != null && i_Target != null)
            {
                if (i_Coin is KingCoin)
                {
                    KingCoin king = i_Coin as KingCoin;
                    if (king.IsEatingMove(i_Target, out Coordinate rivalCoord) && king.AvailableCoordinates.Contains(i_Target))
                    {
                        moveType = eMoveType.Eat;
                        eatCoin(king, GetCoinFromBoard(rivalCoord));
                    }
                    else if (king.isValidMove(i_Target) && king.AvailableCoordinates.Contains(i_Target))
                    {
                        moveType = eMoveType.Step;
                        moveCoin(king, i_Target);
                    }

                    UpdatePlayersAvailableMoves();
                }
                else
                {
                    if (i_Coin.IsEatingMove(i_Target, out Coordinate rivalCoord) &&
                        i_Coin.AvailableCoordinates.Contains(i_Target))
                    {
                        moveType = eMoveType.Eat;
                        eatCoin(i_Coin, GetCoinFromBoard(rivalCoord));
                    }
                    else if (i_Coin.isValidMove(i_Target) &&
                             i_Coin.AvailableCoordinates.Contains(i_Target))
                    {
                        moveType = eMoveType.Step;
                        moveCoin(i_Coin, i_Target);
                    }
                    // If needs to be turned to a King coin
                    if (hasReachedTheFarSideOfTheBoard(i_Coin))
                    {
                        KingCoin newKing   = i_Coin.MakeKing();
                        Player   coinOwner = GetCoinOwner(i_Coin);
                        Board.RemoveCoinFromBoard(i_Coin);
                        coinOwner.CoinsList.Remove(i_Coin);
                        coinOwner.CoinsList.Add(newKing);
                        Board.SetCoinOnBoard(newKing);
                    }
                }

                UpdatePlayersAvailableMoves();
            }

            return(moveType);
        }
Exemple #9
0
        public eMoveType TakeMoveFromPlayer()
        {
            eMoveType moveType = eMoveType.None;

            if (CurrentPlayer is Computer)
            {
                moveType = computerMove(CurrentPlayer as Computer);
            }
            else
            {
                moveType = realPlayerMove();
            }

            m_Checkers.UpdatePlayersAvailableMoves();
            return(moveType);
        }
        private void updateListOfLegalMoves(
            int i_FromSpotRow,
            int i_FromSpotCol,
            int i_ToSpotRow,
            int i_ToSpotCol,
            eMoveType i_KindOfMove)
        {
            List <LegalMoves> legalMoves;

            if (i_KindOfMove == eMoveType.Regular)
            {
                legalMoves = r_LegalMoves;
            }
            else
            {
                legalMoves = r_LegalJumpMoves;
            }

            legalMoves.Add(new LegalMoves(i_FromSpotRow, i_FromSpotCol, i_ToSpotRow, i_ToSpotCol, i_KindOfMove));
        }
        private void getRandInstruction(out string o_StartCellId, out string o_DestinationCellId, bool i_NeedToJumpOver)
        {
            Random    rndNum        = new Random();
            int       countCheckers = m_Players[(int)ePlayerId.Computer].ChekersList.Count;
            int       rndChecker    = rndNum.Next(0, countCheckers);
            eMoveType moveType      = i_NeedToJumpOver ? eMoveType.JumpOver : eMoveType.SimpleMove;

            o_DestinationCellId = null;
            o_StartCellId       = m_Players[(int)ePlayerId.Computer].ChekersList[rndChecker];
            while ((i_NeedToJumpOver && !m_Board[o_StartCellId].NeedToJumpOver()) || m_Board[o_StartCellId].OptionsList.Count == k_Empty)
            {
                rndChecker    = (rndChecker + 1) % countCheckers;
                o_StartCellId = m_Players[(int)ePlayerId.Computer].ChekersList[rndChecker];
            }

            foreach (string optionStr in m_Board[o_StartCellId].OptionsList.Keys)
            {
                if (m_Board[o_StartCellId].OptionsList[optionStr] == moveType)
                {
                    o_DestinationCellId = optionStr;
                    break;
                }
            }
        }
Exemple #12
0
    private void MoveOver(eMoveType movetype)
    {
        int        index = 0;
        Transform  trans;
        GameObject obj = null;

        if (movetype == eMoveType.LeftAndUp)//向左或向上滑动
        {
            if (mItemIndexDic.TryGetValue(mMaxIndex, out index))
            {
                trans = mItemList[index].transform;
            }
            else
            {
                SQDebug.LogError("maxIndex is null");
                return;
            }

            for (int i = 0; i < CountPerLine; i++)
            {
                if (mItemIndexDic.TryGetValue(mMinIndex + i, out index))//找到index在list列表中对应位置
                {
                    obj = mItemList[index];
                    if (mMaxIndex + 1 + i > mAllCount - 1)
                    {
                        obj.gameObject.SetActive(false);
                    }
                    else
                    {
                        obj.gameObject.SetActive(true);
                        DispatchEvent(eFuiScrollViewEvent.UpdateItem, mMaxIndex + 1 + i, obj);
                    }
                    SetMoveItemPos(i, movetype, obj, trans);           //设置obj位置
                    mItemIndexDic.Remove(mMinIndex + i);
                    if (!mItemIndexDic.ContainsKey(mMaxIndex + i + 1)) //将新的index映射到list
                    {
                        mItemIndexDic.Add(mMaxIndex + i + 1, index);
                    }
                }
            }
            //重新设置当前最小index和最大index
            mMinIndex += CountPerLine;
            mMaxIndex += CountPerLine;
            if (mMaxIndex > mAllCount - 1)
            {
                mMaxIndex = mAllCount - 1;
            }
        }
        else//向右或向下滑动
        {
            if (mItemIndexDic.TryGetValue(mMinIndex, out index))
            {
                trans = mItemList[index].transform;
            }
            else
            {
                SQDebug.LogError("minIndex is null");
                return;
            }
            int mindex = mMaxIndex - mMaxIndex % CountPerLine;
            for (int i = 0; i < CountPerLine; i++)
            {
                if (mItemIndexDic.TryGetValue(mindex + i, out index))//找到index在list列表中对应位置
                {
                    obj = mItemList[index];
                    obj.gameObject.SetActive(true);
                    DispatchEvent(eFuiScrollViewEvent.UpdateItem, mMinIndex - CountPerLine + i, obj);
                    SetMoveItemPos(i, movetype, obj, trans);                      //设置obj位置
                    mItemIndexDic.Remove(mindex + i);
                    if (!mItemIndexDic.ContainsKey(mMinIndex - CountPerLine + i)) //将新的index映射到list
                    {
                        mItemIndexDic.Add(mMinIndex - CountPerLine + i, index);
                    }
                }
            }
            //重新设置当前最小index和最大index
            mMinIndex -= CountPerLine;
            mMaxIndex  = mindex - 1;
        }
    }
 private static int getValueType(eMoveType i_Type)
 {
     return((int)i_Type);
 }
Exemple #14
0
	void OnDashBack( AsIMessage _msg)
	{
		Msg_DashBackIndication msg = _msg as Msg_DashBackIndication;

		m_MoveRecognition = true;

		m_Entity.SetProperty( eComponentProperty.MOVING, true);
		m_Entity.SetProperty( eComponentProperty.MOVE_TYPE, eMoveType.Back);
		m_MoveType = eMoveType.Back;

		m_RemainDistance = msg.distance_;

		Vector3[] _newPath = null;
		
		m_Direction = msg.direction_.normalized * msg.distance_;
		m_MoveSpeed = msg.distance_ / msg.time_ * 1000f;
		_newPath = NavMeshFinder.Instance.PathFind_type1( transform.position, transform.position + m_Direction);
		
		if( null != _newPath)
			m_charMover.SetPath( _newPath);

		CancelInvoke( "RefreshAutoMoveDestination");
	}
Exemple #15
0
	void OnWarp( AsIMessage _msg)
	{
		if( this.Entity.EntityType != eEntityType.USER)
		{
			Debug.LogError( "AsMover::OnWarp: this entity is npc. invalid message delivery");
		}
		else
		{
			Msg_WarpIndication warp = _msg as Msg_WarpIndication;

			m_MoveRecognition = true;

			m_Entity.SetProperty( eComponentProperty.MOVING, true);
			m_Entity.SetProperty( eComponentProperty.MOVE_TYPE, eMoveType.Dash);
			m_MoveType = eMoveType.Warp;

			m_Direction = warp.direction_ * warp.distance_;
			m_Direction.y = 0;

			m_WarpPath = NavMeshFinder.Instance.PathFind( transform.position, transform.position + m_Direction);
			//if( null != m_WarpPath)
			//	m_charMover.SetPath( _newPath);
		}

		CancelInvoke( "RefreshAutoMoveDestination");
	}
Exemple #16
0
 public void SetMoveType(eMoveType type)
 {
     this.m_moveType = type;
 }
Exemple #17
0
 public Route(eMoveType moveType)
 {
     this.m_moveType         = moveType;
     this.m_moveRoutePosList = new List <Vector3>();
     this.m_routeListIndex   = 0;
 }
	public Msg_OtherUserMoveIndicate( AS_SC_CHAR_MOVE _move)
	{
		m_MessageType = eMessageType.MOVE_OTHER_USER_INDICATION;

		sessionIdx_ = _move.nSessionIdx;
		charUniqKey_ = _move.nCharUniqKey;
	
		curPosition_ = _move.sCurPosition;
		destPosition_ = _move.sDestPosition;

		moveType_ = ( eMoveType)_move.nMoveType;
	}
        private void updateMove(int i_FromSpotRow, int i_FromSpotColumn, int i_ToSpotRow, int i_ToSpotColumn, eMoveType i_KindOfMove)
        {
            int movementRow, movmentCol;

            if (i_KindOfMove.Equals(eMoveType.Jump))
            {
                movementRow = i_FromSpotRow + getDirectionType(i_FromSpotRow, i_ToSpotRow);
                movmentCol  = i_FromSpotColumn + getDirectionType(i_FromSpotColumn, i_ToSpotColumn);
                r_Board.SetCellValue(movementRow, movmentCol, eSymboleType.SpaceSymbole);
                m_LastPlayer.DeleteGamePawn(movementRow, movmentCol);
            }

            r_Board.SetCellValue(i_ToSpotRow, i_ToSpotColumn, r_Board.Board[i_FromSpotRow, i_FromSpotColumn].Value);
            m_CurrentPlayer.UpdateGamePawns(
                i_FromSpotRow,
                i_FromSpotColumn,
                i_ToSpotRow,
                i_ToSpotColumn,
                r_Board.Board[i_ToSpotRow, i_ToSpotColumn].Value);
            r_Board.SetCellValue(i_FromSpotRow, i_FromSpotColumn, eSymboleType.SpaceSymbole);
        }
Exemple #20
0
	void StackMovePacket( eMoveType _type, Vector3 _curPos, Vector3 _destPos)
	{
		topInfo = new SavedMoveInfo( _type, _curPos, _destPos);
		secondInfo = topInfo;
	}
Exemple #21
0
	void OnMoveAuto( AsIMessage _msg)
	{
		if( this.Entity.EntityType != eEntityType.USER)
		{
			Debug.LogError( "AsMover::OnMoveAuto: this entity is npc. invalid message delivery");
		}
		else
		{
			CancelInvoke( "RefreshAutoMoveDestination");

			Msg_AutoMove msg = _msg as Msg_AutoMove;

			m_MoveRecognition = true;

			m_MoveSpeed = m_Entity.GetProperty<float>( eComponentProperty.MOVE_SPEED);
			m_Entity.SetProperty( eComponentProperty.MOVING, true);
			m_Entity.SetProperty( eComponentProperty.MOVE_TYPE, eMoveType.Auto);
			m_MoveType = eMoveType.Auto;
			m_Direction = msg.targetPosition_ - msg.curPos_;
			m_Direction.y = 0;
			m_Direction = m_Direction.normalized * m_PreCalcultateRatio;

			Vector3[] _newPath = NavMeshFinder.Instance.PathFind( transform.position, transform.position + m_Direction);
			if( null != _newPath)
				m_charMover.SetPath( _newPath);

			InvokeRepeating( "RefreshAutoMoveDestination", 0, m_AutoMoveInterval);
		}
	}
Exemple #22
0
 public void SetMoveType(eMoveType type)
 {
     mMoveType = type;
 }
Exemple #23
0
	void OnForcedMove( AsIMessage _msg)
	{
		Msg_ForcedMoveIndication msg = _msg as Msg_ForcedMoveIndication;

		m_MoveRecognition = true;

		m_Entity.SetProperty( eComponentProperty.MOVING, true);
		m_MoveType = eMoveType.ForcedMove;

		m_MoveSpeed = forcedMovementSpeed;

		Vector3[] path = NavMeshFinder.Instance.PathFind_type1( m_Entity.transform.position, msg.destination_);
//		path[0] = msg.destination_;
		m_charMover.SetPath( path);

		if( path.Length > 0)
			m_Entity.HandleMessage( new Msg_ForcedMove_Sync( path[path.Length - 1]));
	}
Exemple #24
0
	void OnJump( AsIMessage _msg)
	{
		if ( eMessageType.JUMP_MSG == _msg.MessageType)
		{
			Msg_Jump msgJump = _msg as Msg_Jump;
			if ( null != msgJump)
			{
				Debug.Log( "OnJump");
				m_Entity.SetProperty( eComponentProperty.MOVING, true);
				m_Entity.SetProperty( eComponentProperty.MOVE_TYPE, eMoveType.Jump);

				m_MoveRecognition = true;

				m_MoveType = eMoveType.Jump;
				m_vec3TargetPos = msgJump.m_vec3TargetPos;

				msgJump.m_fJumpSpeed -= ( m_fMaxReadyTime + 0.23f);
				if( 0.0f == msgJump.m_fJumpSpeed)
					msgJump.m_fJumpSpeed = 1.0f;
				m_MoveSpeed = ( m_vec3TargetPos - transform.position).magnitude / msgJump.m_fJumpSpeed;
				m_IsJump = true;
//				m_fReadyTime = Time.realtimeSinceStartup;
				m_fReadyTime = Time.time;
			}
		}
	}
Exemple #25
0
	void OnDash( AsIMessage _msg)
	{
		Msg_DashIndication msg = _msg as Msg_DashIndication;

		m_MoveRecognition = true;

		m_Entity.SetProperty( eComponentProperty.MOVING, true);
		m_Entity.SetProperty( eComponentProperty.MOVE_TYPE, eMoveType.Dash);
		m_MoveType = eMoveType.Dash;

		m_RemainDistance = msg.distance_;

		Vector3[] _newPath = null;

		switch( m_Entity.EntityType)
		{
		case eEntityType.USER:
			m_Direction = msg.direction_.normalized * msg.distance_;
			m_MoveSpeed = msg.distance_ / msg.time_ * 1000f;
			_newPath = NavMeshFinder.Instance.PathFind_type1( transform.position, transform.position + m_Direction);
//			ShowPoint( transform.position + m_Direction);//$yde
//			ShowPath( _newPath);//$yde
			if( null != _newPath)
			{
				m_charMover.SetPath( _newPath);

//				float dist = GetNavPathDistance( transform.position, transform.position + m_Direction);
//				m_MoveSpeed = dist / msg.time_ * 1000f;
//				m_Direction = msg.direction_.normalized * msg.distance_;
			}
			break;
		case eEntityType.NPC:
			m_Direction = msg.direction_.normalized * msg.distance_;
			m_MoveSpeed = msg.distance_ / msg.time_ * 1000f;
			_newPath = NavMeshFinder.Instance.PathFind_type1( transform.position, transform.position + m_Direction);
			if( null != _newPath)
			{
				m_charMover.SetPath( _newPath);

//				m_MoveSpeed = msg.distance_ / msg.time_ * 1000f;
//				m_Direction = msg.direction_.normalized * msg.distance_;
			}
			break;
		}

		CancelInvoke( "RefreshAutoMoveDestination");
	}
Exemple #26
0
 public Route( )
 {
     this.m_moveType         = eMoveType.OrderAsc;
     this.m_moveRoutePosList = new List <Vector3>();
     this.m_routeListIndex   = 0;
 }
Exemple #27
0
 public Move(Piece i_CurrentPiece, Piece i_TargetPiece)
 {
     this.m_CurrentPiece = i_CurrentPiece;
     this.m_TargetPiece  = i_TargetPiece;
     this.m_MoveType     = eMoveType.Diagonal;
 }
	public Msg_OtherUserMoveIndicate( UInt16 _sessionIdx, UInt32 _charUniqKey, Vector3 _curPos, Vector3 _destPos, eMoveType _moveType)
	{
		m_MessageType = eMessageType.MOVE_OTHER_USER_INDICATION;

		sessionIdx_ = _sessionIdx;
		charUniqKey_ = _charUniqKey;
	
		curPosition_ = _curPos;
		destPosition_ = _destPos;

		moveType_ = _moveType;
	}
Exemple #29
0
	public void MovePacketRefresh( eMoveType _type, Vector3 _curPos, Vector3 _destPos)
	{
		if( CheckWarpConfirmed() == true)
		{
//			Debug.LogError("AsPlayerFsm::MovePacketSynchronize: trying send move packet");
			return;
		}
		
		StackMovePacket( _type, _curPos, _destPos);

//		Debug.Log( "MovePacketRefresh: curPos = " + _curPos + ", destPos = " + _destPos + ", dist = " + Vector3.Distance( _curPos, _destPos));
		if( enableRefresh == true)
		{
			SendingPacket();
			StartCoroutine( "RefreshDelay", refreshRate);
		}
	}
            public bool RenderObjectProperties(GUIContent label)
            {
                bool dataChanged = false;

                _gameObject     = SerializationEditorGUILayout.ObjectField(_gameObject, "Game Object", ref dataChanged);
                _transformFlags = SerializationEditorGUILayout.ObjectField(_transformFlags, "Transform Flags", ref dataChanged);
                _moveType       = SerializationEditorGUILayout.ObjectField(_moveType, "Move Type", ref dataChanged);
                _easeType       = SerializationEditorGUILayout.ObjectField(_easeType, "Ease Type", ref dataChanged);

                EditorGUI.BeginChangeCheck();
                _duration    = EditorGUILayout.FloatField("Duration", _duration);
                dataChanged |= EditorGUI.EndChangeCheck();

                bool targetChanged = false;

                _targetType = SerializationEditorGUILayout.ObjectField(_targetType, "Target Type", ref targetChanged);
                if (targetChanged)
                {
                    dataChanged = true;

                    _targetTransform = new GameObjectRef();
                    _targetPosition  = Vector3.zero;
                    _targetRotation  = Quaternion.identity;
                    _targetScale     = Vector3.one;
                }

                switch (_targetType)
                {
                case eTargetType.Transform:
                {
                    _targetTransform = SerializationEditorGUILayout.ObjectField(_targetTransform, new GUIContent("Target Type"), ref dataChanged);
                }
                break;

                case eTargetType.LocalDelta:
                case eTargetType.LocalTarget:
                case eTargetType.WorldDelta:
                case eTargetType.WorldTarget:
                {
                    if ((_transformFlags & eTransformFlag.Translate) != 0)
                    {
                        EditorGUI.BeginChangeCheck();
                        _targetPosition = EditorGUILayout.Vector3Field("Translation", _targetPosition);
                        dataChanged    |= EditorGUI.EndChangeCheck();
                    }
                    if ((_transformFlags & eTransformFlag.Rotate) != 0)
                    {
                        EditorGUI.BeginChangeCheck();
                        _targetRotation.eulerAngles = EditorGUILayout.Vector3Field("Rotation", _targetRotation.eulerAngles);
                        dataChanged |= EditorGUI.EndChangeCheck();
                    }
                    if ((_transformFlags & eTransformFlag.Scale) != 0)
                    {
                        EditorGUI.BeginChangeCheck();
                        _targetScale = EditorGUILayout.Vector3Field("Scale", _targetScale);
                        dataChanged |= EditorGUI.EndChangeCheck();
                    }
                }
                break;
                }


                return(dataChanged);
            }
Exemple #31
0
    private void MoveOver(eMoveType movetype)
    {
        int            index = 0;
        Transform      trans;
        ChatScrollItem item       = null;
        float          itemHeight = 0;       //item高度

        if (movetype == eMoveType.LeftAndUp) //向左或向上滑动
        {
            if (mTran.localPosition.y <= mNextDownPos)
            {
                return;
            }
            if (mItemIndexDic.TryGetValue(mMaxIndex, out index))
            {
                trans = mItemList[index].transform;
            }
            else
            {
                SQDebug.LogError("maxIndex is null");
                return;
            }
            //最上边的item移动到最下边
            //最新的最底面的item
            index      = mItemIndexDic[mMinIndex];//数据位置对应的gameobject位置
            item       = mItemList[index];
            itemHeight = item.contentHeight;
            mMaxIndex++;
            //新的最底端item数据对应的gameobject位置
            int topIndex = mItemIndexDic[mMinIndex];
            mItemIndexDic[mMaxIndex] = topIndex;
            //下次滑动到顶端的位置
            //SQDebug.Log("mNextUpPos:" + mNextUpPos);
            mNextUpPos += (itemHeight + SpaceY);
            //新的最上边的item index
            mItemIndexDic.Remove(mMinIndex);//删除之前最顶端的记录
            mMinIndex++;

            item.gameObject.SetActive(true);
            DispatchEvent(eFuiScrollViewEvent.UpdateItem, mMaxIndex, item.transform.GetChild(0).gameObject);
            //重新设置最底下item的位置和大小
            item.contentHeight = NGUIMath.CalculateRelativeWidgetBounds(item.transform).size.y;
            ChatScrollItem lastMax = mItemList[mItemIndexDic[mMaxIndex - 1]];//之前最大的item
            Vector3        vec     = lastMax.transform.localPosition;
            vec.y -= (lastMax.contentHeight + SpaceY);
            item.transform.localPosition = vec;//最终位置
            //下次滑动到底端的位置
            float last = mNextDownPos;
            mNextDownPos += (item.contentHeight + SpaceY);
            //SQDebug.Log("mMinIndex:" + mMinIndex + "   mMaxIndex: " + mMaxIndex + " contentHeight:" + item.contentHeight + "mNextUpPos:" + mNextUpPos + "mNextDownPos:" + mNextDownPos + item.contentHeight  + " last:" + (mNextDownPos - last - 50));
        }
        else//向右或向下滑动
        {
            if (mTran.localPosition.y >= mNextUpPos)
            {
                return;
            }
            //最下边的item移动到最上边
            //最新的最顶端的item
            index      = mItemIndexDic[mMaxIndex];//数据位置对应的gameobject位置
            item       = mItemList[index];
            itemHeight = item.contentHeight;
            mMinIndex--;
            //新的最顶端item数据对应的gameobject位置
            int topIndex = mItemIndexDic[mMaxIndex];
            mItemIndexDic[mMinIndex] = topIndex;
            //下次滑动到顶端的位置
            mNextDownPos -= (itemHeight + SpaceY);
            //新的最底端的item index
            mItemIndexDic.Remove(mMaxIndex);//删除之前最底端的记录
            mMaxIndex--;

            item.gameObject.SetActive(true);
            DispatchEvent(eFuiScrollViewEvent.UpdateItem, mMinIndex, item.transform.GetChild(0).gameObject);
            //重新设置最底下item的位置和大小
            item.contentHeight = NGUIMath.CalculateRelativeWidgetBounds(item.transform).size.y;
            ChatScrollItem lastMin = mItemList[mItemIndexDic[mMinIndex + 1]];//之前最小的item
            Vector3        vec     = lastMin.transform.localPosition;
            vec.y += (item.contentHeight + SpaceY);
            item.transform.localPosition = vec;//最终位置
            //下次滑动到顶端的位置
            float last = mNextUpPos;
            mNextUpPos -= (item.contentHeight + SpaceY);
            //SQDebug.Log("mMinIndex:" + mMinIndex + "   mMaxIndex: " + mMaxIndex + " contentHeight:" + item.contentHeight + "mNextUpPos:" + mNextUpPos + item.contentHeight + "mNextDownPos:" + mNextDownPos + " last:"+(mNextUpPos - last + 50));
        }
    }
Exemple #32
0
	void OnMoveInfo( AsIMessage _msg)
	{
		Msg_MoveInfo msg = _msg as Msg_MoveInfo;

		m_MoveRecognition = true;
		m_MoveSpeed = m_Entity.GetProperty<float>( eComponentProperty.MOVE_SPEED);// / 100;
		m_Entity.SetProperty( eComponentProperty.MOVING, true);
		m_Entity.SetProperty( eComponentProperty.MOVE_TYPE, eMoveType.Normal);
		m_MoveType = eMoveType.Normal;

		if( this.Entity.EntityType == eEntityType.NPC)
		{
			Vector3[] path = new Vector3[1];
			path[0] = msg.targetPosition_;
			m_charMover.SetPath( path);
		}
		else
		{
			Vector3[] _newPath = NavMeshFinder.Instance.PathFind( transform.position, msg.targetPosition_);
			if( null != _newPath)
				m_charMover.SetPath( _newPath);

		}
		CancelInvoke( "RefreshAutoMoveDestination");
	}