Ejemplo n.º 1
0
    public void walkLocalPlayer(int currentX, int currentY, int dir)
    {
        /*
         * targetTransform.Translate(VRAR_Level.getNeighborDistance(VRAR_Level.getCounterTile(dir)));
         * float y = GameStateManager.getInstance().getCurrentLevel().getTileFromIndexPos(currentX, currentY).hexObject.lossyScale.y * 0.447f - this.localPlayer.GetObject().transform.position.y;
         * localPlayer.GetObject().transform.Translate(new Vector3(0f, y * LevelManager.TILE_SCALE, 0f));
         * this.spawnLevel(currentX, currentY);
         * this.updateSight(currentX, currentY);
         *
         * foreach (BasePlayer basePlayer in GamePlayManagerAR.instance.GetPlayers().Values)
         * {
         *  if (basePlayer.GetPlayerId() != this.localPlayer.GetPlayerId())
         *  {
         *      this.walkExternalPlayer(currentX, currentY, basePlayer, VRAR_Level.getCounterTile(dir));
         *  }
         * }*/

        if (this.localPlayerTranslateWrapper == null)
        {
            this.localPlayerTranslateWrapper = new TileRenderer.SlowTranslateWrapper(this.targetTransform);
        }
        this.SlowTranslate(this.localPlayerTranslateWrapper, VRAR_Level.getNeighborDistance(VRAR_Level.getCounterTile(dir)), speed * LevelManager.TILE_SCALE, () =>
        {
            if (GamePlayManagerAR.instance.localPlayer != null)
            {//update animation
                GamePlayManagerAR.instance.localPlayer.GetObject().transform.localEulerAngles = new Vector3(0, directionToRotation(dir), 0);
                m_Animator = GamePlayManagerAR.instance.localPlayer.GetObject().GetComponent <Animator>();
                m_Animator.SetBool("isWalkingLocally", true);
            }

            this.spawnLevel(currentX, currentY);
            this.updateSight(currentX, currentY);
        }, () => {
            if (GamePlayManagerAR.instance.localPlayer != null)
            {//update animation
                m_Animator = GamePlayManagerAR.instance.localPlayer.GetObject().GetComponent <Animator>();
                m_Animator.SetBool("isWalkingLocally", false);
            }
            this.spawnLevel(currentX, currentY);
            this.updateSight(currentX, currentY);
        });

        //float y = GameStateManager.getInstance().getCurrentLevel().getTileFromIndexPos(this.localPlayer.GetCurrentVec().x, this.localPlayer.GetCurrentVec().y).hexObject.lossyScale.y * 0.447f - this.localPlayer.GetObject().transform.position.y;
        //float y = GameStateManager.getInstance().getCurrentLevel().getTileFromIndexPos(currentX, currentY).hexObject.lossyScale.y * 0.447f - this.localPlayer.GetObject().transform.position.y;
        float y = localPlayer.GetObject().transform.position.y - GameStateManager.getInstance().getCurrentLevel().getTileFromIndexPos(currentX, currentY).height_ * 0.1339f;

        this.SlowTranslatePlayer(this.localPlayer, new Vector3(0f, -y, 0f), speed * LevelManager.TILE_SCALE, false);
        //localPlayer.GetObject().transform.position = new Vector3(localPlayer.GetObject().transform.position.x, GameStateManager.getInstance().getCurrentLevel().getTileFromIndexPos(currentX, currentY).height_ * LevelManager.TILE_SCALE * 0.447f, localPlayer.GetObject().transform.position.z);

        foreach (BasePlayer basePlayer in GamePlayManagerAR.instance.GetPlayers().Values)
        {
            if (basePlayer.GetPlayerId() != this.localPlayer.GetPlayerId())
            {
                this.walkExternalPlayer(currentX, currentY, basePlayer, VRAR_Level.getCounterTile(dir), false);
            }
        }
    }
Ejemplo n.º 2
0
    //Moves the character and return true if succesful, return false if there is no tile or its not walkable
    public bool Move(int direction)
    {
        VRAR_Tile targetTile = GameStateManager.getInstance().getCurrentLevel().getAdjacentTile(_currentTilePos.x, _currentTilePos.y, VRAR_Level.getCounterTile(direction));

        //if (targetTile == null || !targetTile.walkable)
        // return false;

        _currentTilePos = new Vector2Int(targetTile.tileIndex_X, targetTile.tileIndex_Y);
        return(true);
    }
Ejemplo n.º 3
0
    public void QueueMove(int direction)
    {
        BasePlayer player = GamePlayManagerAR.instance.localPlayer;
        VRAR_Tile  tile   = GameStateManager.getInstance().getCurrentLevel().getAdjacentTile(player.GetCurrentVec().x, player.GetCurrentVec().y, VRAR_Level.getCounterTile(direction));

        if (tile == null || !tile.walkable)
        {
            return;
        }

        var moveMessage = new MoveRequestMessage();

        moveMessage.direction = direction;
        client.Send(CustomNetMsg.MoveRequest, moveMessage);
    }
Ejemplo n.º 4
0
    //Moves the character and return true if succesful, return false if there is no tile or its not walkable
    public bool Move(int direction)
    {
        VRAR_Tile targetTile = GameStateManager.instance.getCurrentLevel().getAdjacentTile(_currentTilePos.x, _currentTilePos.y, VRAR_Level.getCounterTile(direction));

        //if (targetTile == null || !targetTile.walkable)
        // return false;

        _currentTilePos            = new Vector2Int(targetTile.tileIndex_X, targetTile.tileIndex_Y);
        _object.transform.position = targetTile.tileGameObject.position + new Vector3(0, targetTile.height_, 0);
        return(true);
    }
Ejemplo n.º 5
0
    void GotMove(NetworkMessage netMsg)
    {
        var msg = netMsg.ReadMessage <MoveMessage>();

        /*
         * BasePlayer player = players[msg.id];
         * VRAR_Tile tile = GameStateManager.getInstance().getCurrentLevel().getAdjacentTile(player.tileLocation.x, player.tileLocation.y, VRAR_Level.getCounterTile(msg.direction));
         * player.tileLocation = new Vector2Int(tile.tileIndex_X, tile.tileIndex_Y);
         */



        BasePlayer player = players[msg.id];

        VRAR_Tile tile = GameStateManager.getInstance().getCurrentLevel().getAdjacentTile(player.GetCurrentVec().x, player.GetCurrentVec().y, VRAR_Level.getCounterTile(msg.direction));

        player.Move(msg.direction);

        // local player
        if (IsMyId(msg.id))
        {
            // move the world.
            TileRenderer.instance.walkLocalPlayer(player.GetCurrentVec().x, player.GetCurrentVec().y, msg.direction);
        }
        else
        {
            //TileRenderer.instance.walkExternalPlayer(player.GetCurrentVec().x, player.GetCurrentVec().y, player, msg.direction);
            TileRenderer.instance.walkExternalPlayer(GamePlayManagerAR.instance.localPlayer.GetCurrentVec().x, GamePlayManagerAR.instance.localPlayer.GetCurrentVec().y, player, msg.direction, true);
            // move the other player.
            //otherplayer.tilePosition =
        }
    }