Пример #1
0
 public void UnregisterTankConfig(TankConfiguration newConfig)
 {
     if (allTankConfigurations != null && allTankConfigurations.Contains(newConfig))
     {
         allTankConfigurations.Remove(newConfig);
     }
 }
Пример #2
0
 public void RegisterTankConfig(TankConfiguration newConfig)
 {
     if (allTankConfigurations != null && !allTankConfigurations.Contains(newConfig))
     {
         allTankConfigurations.Add(newConfig);
     }
 }
    public override bool Equals(object other)
    {
        TankConfiguration otherTank = other as TankConfiguration;

        if (otherTank == null)
        {
            return(false);
        }

        return
            (MoveForward == otherTank.MoveForward &&
             MoveBackwards == otherTank.MoveBackwards &&
             TurnLeft == otherTank.TurnLeft &&
             TurnRight == otherTank.TurnRight &&
             Shoot == otherTank.Shoot &&
             TankColor == otherTank.TankColor);
    }
Пример #4
0
    public void InitializeTankColors()
    {
        if (TankChoosingMenu.Instance.allTankConfigurations != null && TankChoosingMenu.Instance.allTankConfigurations.Count >= 2)
        {
            TankConfiguration player1Config = TankChoosingMenu.Instance.allTankConfigurations[0];
            player1Color = player1Config.TankColor;
            Player1Tank.GetComponent <SpriteRenderer>().color = player1Color;

            TankConfiguration player2Config = TankChoosingMenu.Instance.allTankConfigurations[1];
            player2Color = player2Config.TankColor;
            Player2Tank.GetComponent <SpriteRenderer>().color = player2Color;
        }
        else
        {
            Player1Tank.GetComponent <SpriteRenderer>().color = player1Color;
            Player2Tank.GetComponent <SpriteRenderer>().color = player2Color;
        }
    }
Пример #5
0
    public void InitializeTankControlls()
    {
        if (TankChoosingMenu.Instance.allTankConfigurations != null && TankChoosingMenu.Instance.allTankConfigurations.Count >= 2)
        {
            TankConfiguration player1Config = TankChoosingMenu.Instance.allTankConfigurations[0];
            p1MoveForward   = player1Config.MoveForward;
            p1MoveBackwards = player1Config.MoveBackwards;
            p1TurnLeft      = player1Config.TurnLeft;
            p1TurnRight     = player1Config.TurnRight;
            p1Shoot         = player1Config.Shoot;

            TankConfiguration player2Config = TankChoosingMenu.Instance.allTankConfigurations[1];
            p2MoveForward   = player2Config.MoveForward;
            p2MoveBackwards = player2Config.MoveBackwards;
            p2TurnLeft      = player2Config.TurnLeft;
            p2TurnRight     = player2Config.TurnRight;
            p2Shoot         = player2Config.Shoot;
        }
    }
Пример #6
0
    public void OnStartGame(TankChoosingWindowManager tankWindowManager)
    {
        allTankConfigurations = new List <TankConfiguration>();
        foreach (TankConfigurationSetupWindow tankConfigSet in tankWindowManager.addedPlayerConfigs)
        {
            GameObject        newConfigGO = new GameObject("PlayerConfig");
            TankConfiguration newConfig   = newConfigGO.AddComponent <TankConfiguration>();

            newConfig.MoveForward   = tankConfigSet.configurationReference.MoveForward;
            newConfig.MoveBackwards = tankConfigSet.configurationReference.MoveBackwards;
            newConfig.TurnLeft      = tankConfigSet.configurationReference.TurnLeft;
            newConfig.TurnRight     = tankConfigSet.configurationReference.TurnRight;
            newConfig.Shoot         = tankConfigSet.configurationReference.Shoot;
            newConfig.TankColor     = tankConfigSet.configurationReference.TankColor;

            newConfig.transform.parent = transform;
            allTankConfigurations.Add(newConfig);
        }

        MenuStateManager.Instance.ChangeScene(MenuStateManager.GameStage.GameArena);
    }
    public void Update()
    {
        if (configurationReference == null)
        {
            configurationReference = GetComponentInChildren <TankConfiguration>();
            if (configurationReference == null)
            {
                GameObject newGO = new GameObject("TankConfig " + tankName);
            }
        }

        if (MoveForwardKey != null)
        {
            MoveForwardKey.text = GetDisplayForKey(configurationReference.MoveForward);
        }
        if (MoveBackwardsKey != null)
        {
            MoveBackwardsKey.text = GetDisplayForKey(configurationReference.MoveBackwards);
        }
        if (TurnLeftKey != null)
        {
            TurnLeftKey.text = GetDisplayForKey(configurationReference.TurnLeft);
        }
        if (TurnRightKey != null)
        {
            TurnRightKey.text = GetDisplayForKey(configurationReference.TurnRight);
        }

        if (ShootKey != null)
        {
            ShootKey.text = GetDisplayForKey(configurationReference.Shoot);
        }

        if (colorCircle != null)
        {
            colorCircle.color = configurationReference.TankColor;
        }
    }