コード例 #1
0
    void Update()
    {
        FloorPadInput.GetEvents(gameObject);
        var coordslist = FloorPadInput.GetPressedCoordinates();
        var players    = GameObject.FindGameObjectsWithTag("Player");

        numberOfPlayers = players.Length;
        // move players if their position isn't held but a neighbor is
        // pop all player coords
        // make new
        foreach (var player in players)
        {
            var extras = player.GetComponent <PlayerExtras>();
            if (extras.PositionIsValid())
            {
                continue;
            }
            Tile tile = extras.GetTile();
            Tile move = tile;
            foreach (var nei in tile.GetNeighbors())
            {
                if (coordslist.Contains(nei.GetCoord()))
                {
                    move = nei;
                    break;
                }
            }
            if (move != tile)
            {
                extras.Move(move);
            }
        }
        foreach (var coord in coordslist)
        {
            bool make = true;
            foreach (var player in players)
            {
                if (player.GetComponent <PlayerExtras>().GetPosition() == coord)
                {
                    make = false;
                    break;
                }
            }
            if (make)
            {
                CreatePlayer(coord);
            }
        }
        foreach (var player in players)
        {
            if (!player.GetComponent <PlayerExtras>().PositionIsValid())
            {
                Destroy(player);
            }
        }
    }
コード例 #2
0
    void Update()
    {
        FloorPadInput.GetEvents(gameObject);

        if (FloorPadInput.GetTile(0, 0))
        {
            Debug.Log("The top left tile was pressed.");
        }

        if (FloorPadInput.GetTile(0, 9))
        {
            Debug.Log("The bottom left tile was pressed.");
        }
        if (FloorPadInput.GetTile(9, 0))
        {
            Debug.Log("The top right tile was pressed.");
        }

        if (FloorPadInput.GetTile(9, 9))
        {
            Debug.Log("The bottom right tile was pressed.");
        }
    }
コード例 #3
0
 void Update()
 {
     FloorPadInput.GetEvents(gameObject);
 }