コード例 #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
    // Clear grid and mark the new currently pressed grids
    private void tilesPressedUpdate()
    {
        activeTiles = new bool[gridSize, gridSize];
        List <Vector2> tilesPressed = FloorPadInput.GetPressedCoordinates();

        foreach (Vector2 tile in tilesPressed)
        {
            activeTiles[(int)tile.x, (int)tile.y] = true;
        }
    }
コード例 #3
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.");
        }
    }
コード例 #4
0
 void Update()
 {
     FloorPadInput.GetEvents(gameObject);
 }
コード例 #5
0
 void OnTileDown(Vector2 coords)
 {
     tileColor = FloorPadInput.GetTileColor(coords);
 }
コード例 #6
0
    public bool PositionIsValid()
    {
        var pos = GetPosition();

        return(FloorPadInput.GetPressedCoordinates().Contains(pos));
    }
 void Start()
 {
     FloorPadInput.Initialize();
 }
 void OnApplicationQuit()
 {
     FloorPadInput.OnQuit();
 }
 void Update()
 {
     FloorPadInput.Update();
 }