Exemple #1
0
    private void EachDirectionButton(MenuItemController directionButton, MenuItemController robotButton, RobotController robotController, string commandName)
    {
        bool isSpawn = commandName.Equals(Command.GetDisplay(Command.SPAWN_COMMAND_ID));
        byte dir     = (byte)Command.byteToDirectionString.ToString().IndexOf(directionButton.name);

        directionButton.SetSprite(isSpawn ? queueSprites[dir] : GetArrow(commandName));
        directionButton.SetCallback(() => DirectionButtonCallback(robotButton, robotController, commandName, dir));
        directionButton.spriteRenderer.transform.localRotation = Quaternion.Euler(Vector3.up * 180 + (isSpawn ? Vector3.zero : Vector3.forward * dir * 90));
        directionButton.spriteRenderer.color = isSpawn ? Color.gray : Color.white;
    }
Exemple #2
0
    public void BindUiToRobotController(short robotId, RobotController robotController)
    {
        MenuItemController             robotButton = Instantiate(genericButton, robotButtonContainer.transform);
        RobotPanelsContainerController container   = robotController.isOpponent ? opponentsRobots : myRobots;

        robotButton.SetSprite(container.GetSprite(robotId));
        robotButton.SetCallback(() => RobotButtonCallback(robotButton, robotController, robotId));
        robotButton.gameObject.SetActive(!robotController.isOpponent);
        int teamLength = robotButtonContainer.menuItems.ToList().Count(m => m.gameObject.activeInHierarchy == !robotController.isOpponent);

        robotButton.transform.localPosition = Vector3.right * (teamLength % 4 * 3 - 4.5f);
        robotButtonContainer.menuItems      = robotButtonContainer.menuItems.ToList().Concat(new List <MenuItemController>()
        {
            robotButton
        }).ToArray();

        container.BindCommandClickCallback(robotController, CommandSlotClickCallback);
    }