示例#1
0
        public void CharacterPlayerDictionaryReturnedByGameSystem()
        {
            Player     me    = new Player("me");
            Player     notme = new Player("not_me");
            GameSystem gs    = new GameSystem(me, notme);

            CharacterClass[] charactersInGame =
                new CharacterClass[] {
                CharacterClass.MELEE,
                CharacterClass.RANGED,
                CharacterClass.PSYONIC,
                CharacterClass.HACKER
            };
            gs.AssignPlayerCharacters(me, charactersInGame);
            gs.AssignPlayerCharacters(notme, charactersInGame);
            Dictionary <Player, Character[]> tmp = gs.GetPlayersCharacters();

            Assert.NotNull(tmp);
            Assert.AreEqual(tmp.Count, 2);

            Character[] chs = new Character[charactersInGame.Length];
            tmp.TryGetValue(me, out chs);
            Array.ForEach(chs, c => Debug.Log(c.name));

            tmp.TryGetValue(notme, out chs);
            Array.ForEach(chs, c => Debug.Log(c.name));
        }
示例#2
0
        public void CharactersReturnedByGameSystem()
        {
            Player     me    = new Player("me");
            Player     notme = new Player("not_me");
            GameSystem gs    = new GameSystem(me, notme);

            CharacterClass[] charactersInGame =
                new CharacterClass[] {
                CharacterClass.MELEE,
                CharacterClass.RANGED,
                CharacterClass.PSYONIC,
                CharacterClass.HACKER
            };
            gs.AssignPlayerCharacters(me, charactersInGame);
            gs.AssignPlayerCharacters(notme, charactersInGame);

            Assert.AreEqual(gs.AllCharacters().Count, charactersInGame.Length * gs.Players().Count);
        }
示例#3
0
        public void GameSetup()
        {
            //create players
            Player me    = new Player("me");
            Player notme = new Player("not_me");

            //make the gamesystem
            GameSystem gs = new GameSystem(me, notme);

            //this should be easier to read
            CharacterClass[] charactersInGame =
                new CharacterClass[] {
                CharacterClass.MELEE,
                CharacterClass.RANGED,
                CharacterClass.PSYONIC,
                CharacterClass.HACKER
            };
            gs.AssignPlayerCharacters(me, charactersInGame);
            gs.AssignPlayerCharacters(notme, charactersInGame);

            //control should be in players hands now

            //other stuff ...
        }
示例#4
0
    //creates players,
    //the game,
    //the character objects
    //
    void Start()
    {
        Player player1 = new Player("PLAYER_1");
        Player player2 = new Player("PLAYER_2");

        //create the game
        gameSystem         = new GameSystem(player1, player2);
        gameSystem.monoref = this;

        //make sure all players get their characters, for >2 make a loop
        gameSystem.AssignPlayerCharacters(player1, classes);
        gameSystem.AssignPlayerCharacters(player2, classes);

        //assign the player script to the human player
        GameObject.Find("Player").GetComponent <PlayerController>().player = player1;
        //assign the player script to the AI player
        Camera.main.GetComponent <AIMover>().player = player2;

        //Material sprites_default = new Material(Shader.Find("Sprites/Default"));;

        //Parker
        int animCounter = 0;

        //create the actual sprites and tie the scripts to gameobjects
        for (int i = 0; i < gameSystem.Players().Count; i++)
        {
            Player p = gameSystem.Players()[i];
            foreach (Character c in p.characters.Values)
            {
                //rename characters
                c.name = p.name + "_" + c.name;
                GameObject tmp = new GameObject(p.name + " " + c.characterclass.ToString());

                //add the MonoBehaviour OR ELSE!
                Agent ctmp = tmp.AddComponent <Agent>();

                //reference to mono and script
                ctmp.character  = c;//dont forget
                c.gameCharacter = tmp.transform;

                //Add the agent stats for each Character
                switch (c.characterclass)
                {
                case CharacterClass.MELEE:
                    c.stats.health    = 14;
                    c.stats.maxHealth = 14;
                    c.stats.speed     = 3;
                    c.stats.range     = 1;
                    c.stats.aoeRange  = 0;
                    c.stats.attackdmg = 4;
                    break;

                case CharacterClass.HACKER:
                    c.stats.health    = 7;
                    c.stats.maxHealth = 7;
                    c.stats.speed     = 2;
                    c.stats.range     = 4;
                    c.stats.aoeRange  = 1;
                    c.stats.attackdmg = 2;
                    break;

                case CharacterClass.RANGED:
                    c.stats.health    = 7;
                    c.stats.maxHealth = 7;
                    c.stats.speed     = 2;
                    c.stats.range     = 4;
                    c.stats.aoeRange  = 0;
                    c.stats.attackdmg = 3;
                    break;

                case CharacterClass.PSYONIC:
                    c.stats.health    = 7;
                    c.stats.maxHealth = 7;
                    c.stats.speed     = 3;
                    c.stats.range     = 3;
                    c.stats.aoeRange  = 0;
                    c.stats.attackdmg = -2;
                    break;
                }

                //put the sprite onto
                SpriteRenderer renderer = tmp.AddComponent <SpriteRenderer>();
                //renderer.sprite=sprites[(int)c.characterclass];
                renderer.material = material;

                //Parker
                Animator anim = tmp.AddComponent <Animator>();
                anim.runtimeAnimatorController = animators[animCounter];
                animCounter++;

                ctmp.Projectile(projectiles[(int)c.characterclass]);

                //hide until ready
                renderer.enabled = false;
            }
        }
        PutCharactersOnBoard();
    }