Ejemplo n.º 1
0
    // Hero: Need to know that it is the hero (job)
    // Enemy: Need to know that it is the enemy (job). Need to generate stats on the fly
    // Mook: Generated based on PlayercreationData.

    public void Initialize(JobActionsList jobList, string name)
    {
        this.playerCreationData = new PlayerCreationData(name, jobList.job);
        this.playerRewards      = new List <PlayerReward>();

        this.CommonInitialization(name);
    }
Ejemplo n.º 2
0
 /*
  * void Update(){
  *
  *      if (Input.GetKeyDown(KeyCode.S)) {
  *              MessagingManager.Broadcast(Messages.RESTART,this.gameObject);
  *      }
  *
  * }
  */
 public void Message(Messages message, GameObject sender)
 {
     switch (message)
     {
     case Messages.RESTART:
         player0Data = PlayerInfoPasser.GetInfo(0);
         player1Data = PlayerInfoPasser.GetInfo(1);
         if (playerA != null)
         {
             if (playerA.GetComponent <PlayerInfo>().State == PlayerInfo.PlayerState.ALIVE)
             {
                 Object.Destroy(playerA);
             }
         }
         if (playerB != null)
         {
             if (playerB.GetComponent <PlayerInfo>().State == PlayerInfo.PlayerState.ALIVE)
             {
                 Object.Destroy(playerB);
             }
         }
         Object.Destroy(healthA);
         Object.Destroy(healthB);
         CreatePlayers();
         break;
     }
 }
Ejemplo n.º 3
0
    public void ShuffleTeams()
    {
        _shuffleIcon.Show();
        //shuffle the list to a random order.
        List <PlayerData> ActivePlayerList = PlayersData.FindAll(item => item.Player.activeSelf);

        PlayersData.Clear();
        for (int i = 0; i < ActivePlayerList.Count; i++)
        {
            PlayerData temp        = ActivePlayerList[i];
            int        RandomIndex = Random.Range(0, ActivePlayerList.Count);
            ActivePlayerList[i]           = ActivePlayerList[RandomIndex];
            ActivePlayerList[RandomIndex] = temp;
        }

        //loop through the list, destroying the players and creating the anew.
        foreach (PlayerData data in ActivePlayerList)
        {
            //save reusable data.
            data.Player.GetComponent <PlayerController>().Resurrect();
            int     playerNumber = data.PlayerID;
            Vector3 position     = data.Player.transform.position;
            //KILL. DIE.
            Destroy(data.Player);
            PlayersData.Remove(data);
            //create a new player.
            PlayerCreationData createData = new PlayerCreationData {
                playerID = playerNumber, Position = position
            };
            createPlayer(createData);
        }
    }
Ejemplo n.º 4
0
 PlayerInfoPasser()
 {
     defaultData             = new PlayerCreationData();
     defaultData.characterID = 0;
     defaultData.weaponID    = 0;
     player0Data             = defaultData;
     player1Data             = defaultData;
 }
Ejemplo n.º 5
0
    public void CreateHero(string heroName)
    {
        // Creates the hero player
        JobActionsList     jobActionsList = GameManager.Instance.models.GetPlayerJobActionsList(Job.HERO);
        PlayerCreationData heroData       = new PlayerCreationData(heroName, Job.HERO);
        Player             hero           = new Player();

        hero.Initialize(jobActionsList, heroName);
        hero.stats.ApplyStatsBasedOnLevel(4);
        this.SetFighter(0, hero);
    }
Ejemplo n.º 6
0
    // Use this for initialization
    void Start()
    {
        player0Data = PlayerInfoPasser.GetInfo(0);
        player1Data = PlayerInfoPasser.GetInfo(1);

        //Debug.Log(PlayerInfoPasser.GetController(0).movement.array[0]);

        CreatePlayers();

        MessagingManager.AddListener(this);
    }
Ejemplo n.º 7
0
    void Update()
    {
        if (Input.GetKeyDown("backspace"))
        {
            ShuffleTeams();
        }

        // We constantly listen for start inputs
        for (int i = 1; i <= maxPlayerCount; i++)
        {
            if (Input.GetButtonDown("Start" + i))
            {
                // we attempt to find the player
                PlayerData playerData = PlayersData.Find(item => item.PlayerID == i);

                if (playerData == null)
                {
                    {
                        PlayerCreationData data = new PlayerCreationData {
                            playerID = i
                        };
                        createPlayer(data);
                    }
                }
                else if (!playerData.Player.activeSelf)
                {
                    activatePlayer(playerData);
                }
            }

            // Check horizontal input to reset
            if (Input.GetAxis("Horizontal" + i) != 0)
            {
                PlayerData playerData = PlayersData.Find(item => item.PlayerID == i);
                if (playerData != null)
                {
                    playerData.InactivityTimer = 0;
                }
            }
        }

        // We will update the inactivity timers
        foreach (PlayerData playerData in PlayersData)
        {
            playerData.InactivityTimer += Time.deltaTime;
            // If an inactivity timer hits the max inactivity deactive the player
            if (playerData.InactivityTimer >= MaxInactivityTime && !playerData.Player.GetComponent <PlayerController>().IsDead)
            {
                deactivatePlayer(playerData);
            }
        }
    }
Ejemplo n.º 8
0
    public void RefreshUI()
    {
        List <PlayerCreationData> playersInQueue = GameManager.Instance.gameState.playerParty.playerQueue.Peek(maxInstantiatedTexts);
        int len = Mathf.Min(playersInQueue.Count, maxInstantiatedTexts);

        for (int i = 0; i < len; i++)
        {
            PlayerCreationData playerData = playersInQueue[i];
            texts[i].text.SetText(playerData.name);
            texts[i].gameObject.SetActive(true);
        }

        for (int i = len; i < maxInstantiatedTexts; i++)
        {
            texts[i].gameObject.SetActive(false);
        }
    }
Ejemplo n.º 9
0
    private void createPlayer(PlayerCreationData data)
    {
        int playerID = data.playerID;
        int teamID   = GetSmallestTeamId();

        //get position
        Vector3 position;

        if (data.Position != Vector3.zero) //default value, if we haven't assigned a custom value.
        {
            position = data.Position;
        }
        else
        {
            position = GetTeamPosition(teamID);
        }


        // Create a new player with this id and give it an active state
        GameObject player = (GameObject)Instantiate(PlayerPrefab, position, Quaternion.identity);

        player.GetComponent <PlayerController>().PlayerNumber = playerID;

        //set the data.
        PlayerData playerData = new PlayerData {
            Player   = player,
            PlayerID = playerID,
            TeamID   = teamID
        };

        player.GetComponent <PlayerController>().TeamID = teamID;

        //set the right texture.
        Texture2D           texture            = GetTexture(playerID, teamID);
        SkinnedMeshRenderer rendererInChildren = player.GetComponentInChildren <SkinnedMeshRenderer>();

        rendererInChildren.material.mainTexture = texture;

        // And add it to the list
        PlayersData.Add(playerData);

        GameManager.instance.Smoke(player.transform.position);
    }
Ejemplo n.º 10
0
    private List <Player> GetNPlayers(int n)
    {
        List <Player> players = new List <Player>();

        for (int i = 0; i < n; i++)
        {
            PlayerCreationData data = playerQueue.Dequeue();
            if (data != null)
            {
                Player player = new Player();
                player.Initialize(data, data.name);
                player.stats.ApplyStatsBasedOnLevel(GameManager.Instance.gameState.playerParty.GetHeroFighter().stats.level);

                OutOfJuiceAilment outOfJuicePrefab = (OutOfJuiceAilment)GameManager.Instance.models.GetCommonStatusAilment("Out of Juice");
                player.ailmentController.AddStatusAilment(Instantiate(outOfJuicePrefab));
                //player.stats.ApplyStatsBasedOnLevel(1);
                players.Add(player);
            }
        }
        return(players);
    }
Ejemplo n.º 11
0
 public void Initialize(PlayerCreationData data, string name)
 {
     this.playerCreationData = data;
     this.CommonInitialization(name);
 }
Ejemplo n.º 12
0
 public static void PassInfo(PlayerCreationData pPlayer0, PlayerCreationData pPlayer1)
 {
     player0Data = pPlayer0;
     player1Data = pPlayer1;
 }