示例#1
0
        public async Task <bool> PostPlayer([FromBody] PlayerSelections selections)

        {
            var PlayerCount = _context.PlayerSelection.Where(p => p.TeamName == selections.TeamName).CountAsync().Result;

            if (PlayerCount < 15)
            {
                try
                {
                    foreach (int i in selections.PlayerKeys)
                    {
                        var selection = new PlayerSelection(selections.TeamName, i);
                        _context.PlayerSelection.Add(selection);

                        await _context.SaveChangesAsync();
                    }
                }
                catch (DbUpdateException)
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }

            return(true);
        }
示例#2
0
 private void Awake()
 {
     if (instance != null)
     {
         Destroy(gameObject);
     }
     else
     {
         instance = this;
         GameObject.DontDestroyOnLoad(gameObject);
     }
 }
示例#3
0
    // Use this for initialization
    void Start()
    {
        PlayerSelectionsScript = GameObject.FindObjectOfType <PlayerSelections>();

        if (PlayerSelectionsScript.player1class == 1)
        {
            Instantiate(Mage, new Vector3(3.15f, 3.15f, 0), Quaternion.identity);
            playerIDScript        = GameObject.FindObjectOfType <PlayerID>();
            playerIDScript.player = 1;
            playerIDScript.toon   = 1;
        }

        if (PlayerSelectionsScript.player2class == 1 && PlayerSelectionsScript.player1class != 1)
        {
            Instantiate(Mage, new Vector3(12, 3.15f, 0), Quaternion.identity);
            playerIDScript        = GameObject.FindObjectOfType <PlayerID>();
            playerIDScript.player = 2;
            playerIDScript.toon   = 1;
        }

        if (PlayerSelectionsScript.player2class == 1 && PlayerSelectionsScript.player1class == 1)
        {
            Instantiate(Mage2, new Vector3(12, 3.15f, 0), Quaternion.identity);
            playerIDScript        = GameObject.FindObjectOfType <PlayerID>();
            playerIDScript.player = 2;
            playerIDScript.toon   = 1;
        }
        /////////////////////////////////////////////////////////////////
        if (PlayerSelectionsScript.player1class == 2)
        {
            Instantiate(Warrior, new Vector3(3.15f, 3.15f, 0), Quaternion.identity);
            playerIDScript        = GameObject.FindObjectOfType <PlayerID>();
            playerIDScript.player = 1;
            playerIDScript.toon   = 2;
        }

        if (PlayerSelectionsScript.player2class == 2 && PlayerSelectionsScript.player1class != 2)
        {
            Instantiate(Warrior, new Vector3(12, 3.15f, 0), Quaternion.identity);
            playerIDScript        = GameObject.FindObjectOfType <PlayerID>();
            playerIDScript.player = 2;
            playerIDScript.toon   = 2;
        }

        if (PlayerSelectionsScript.player2class == 2 && PlayerSelectionsScript.player1class == 2)
        {
            Instantiate(Warrior, new Vector3(12, 3.15f, 0), Quaternion.identity);
            playerIDScript        = GameObject.FindObjectOfType <PlayerID>();
            playerIDScript.player = 2;
            playerIDScript.toon   = 2;
        }
    }
 // Use this for initialization
 void Start()
 {
     PlayerSelectionsScript = GameObject.FindObjectOfType <PlayerSelections>();
     button = GetComponent <Button>();
     button.onClick.AddListener(TaskOnClick);
 }