Exemple #1
0
    /// <summary>
    /// This method receives a command and a username and adds a nextcommand
    /// to the username's player actor.
    /// </summary>
    /// <param name="msgString">message</param>
    /// <param name="user">username</param>
    private static void HandleEnemyCommand(string command, string enemyName, string user)
    {
        if (!GameManager.enemyDictionary.ContainsKey(enemyName))
        {
            return;
        }

        ActorEnemy desiredEnemy = GameManager.enemyDictionary[enemyName];
        string     cmd          = command.Replace("#", "");

        Debug.Log(user + " tried to vote for " + enemyName + " to do " + cmd);
        Commands voteCommand = GetCommand(cmd);

        if (!desiredEnemy.votedCommands.ContainsKey(voteCommand))
        {
            Debug.Log("Success added");
            desiredEnemy.votedCommands.Add(voteCommand, 1);
        }
        else
        {
            Debug.Log("Success counted");
            desiredEnemy.votedCommands[voteCommand]++;
        }
        usersVotedThisTurn.Add(user);
    }
Exemple #2
0
    public Actor SpawnEnemy()
    {
        //Spawn Player Object.
        ActorEnemy spawnedPlayer = enemyPrefab.Spawn();

        //Set position.
        spawnedPlayer.currentPosition = BoardMethod.GetRandomTile();
        Tile emptyTile = BoardMethod.GetTile(spawnedPlayer.currentPosition);

        spawnedPlayer.transform.position = emptyTile.transform.position;

        spawnedPlayer.spriteRenderer.color = Color.red;

        //Set username.
        spawnedPlayer.actorName = GetEnemyName();

        //Add to dictionary so we can reference it later by username.
        enemyDictionary.Add(spawnedPlayer.actorName, spawnedPlayer);

        return(spawnedPlayer);
    }
    IEnumerator MoveEnemies()
    {
        session.enemiesMoving = true;
        yield return(new WaitForSeconds(session.turnDelay));

        if (session.enemies.Count == 0)
        {
            yield return(new WaitForSeconds(session.turnDelay));
        }

        //Loop through List of Enemy objects.
        for (int i = 0; i < session.enemies.Count; i++)
        {
            //Call the MoveEnemy function of Enemy at index i in the enemies List.
            ActorEnemy enemy = session.enemies[i] as ActorEnemy;
            session.enemies[i].SignalDispatch(new SignalMove());

            //Wait for Enemy's moveTime before moving next Enemy
            yield return(new WaitForSeconds(enemy.dataMove.moveTime));
        }

        session.playersTurn   = true;
        session.enemiesMoving = false;
    }