Beispiel #1
0
            //[DataRow(GoblinTypes.archer, typeof(GoblinWarrior))]
            public void ClassValidity(GoblinTypes type, Type expected)
            {
                const int DIFF = 1;
                Entity    ent  = GoblinFactory.createGoblin(type, DIFF);

                try
                {
                    Convert.ChangeType(ent, expected);
                }
                catch
                {
                    Assert.Fail();
                }
            }
Beispiel #2
0
            public void DifficultyRange(GoblinTypes type, int difficulty)
            {
                const int MaxDeviation_ATT = 2;
                const int MaxDeviation_DEF = 2;

                int    targetvalue_att = difficulty * 2;
                int    targetvalue_def = difficulty * 4;
                Entity ent             = GoblinFactory.createGoblin(type, difficulty);
                int    deviation_att   = Math.Abs(targetvalue_att - ent.Attack);
                int    deviation_def   = Math.Abs(targetvalue_def - ent.Defence);

                Assert.IsTrue(deviation_att <= MaxDeviation_ATT);
                Assert.IsTrue(deviation_def <= MaxDeviation_DEF);
            }
Beispiel #3
0
    void Start()
    {
        GameObject tmp = GameObject.FindGameObjectWithTag("GameController");

        controller = tmp.GetComponent <GameController>();
        if (controller == null)
        {
            Debug.LogError("Unable to find gamecontroller scripts");
        }

        anim = GetComponent <Animator>();
        controller.AddScore(1);

        int random = Random.Range(0, 9);

        if (controller.level == 2)
        {
            if (random >= 5)
            {
                Goblin newSpawn = gameObject.AddComponent <FastGoblin>();
                factory = new FastGoblinFactory();
            }
            else
            {
                factory = new RegularGoblinFactory();
            }
        }
        else if (controller.level == 3)
        {
            Debug.Log("random: " + random);

            if (random >= 5)
            {
                Goblin newSpawn = gameObject.AddComponent <FastGoblin>();
                factory = new FastGoblinFactory();
            }
            else
            {
                Goblin newSpawn = gameObject.AddComponent <ThiefGoblin>();
                factory = new ThiefGoblinFactory();
            }
        }
        else
        {
            factory = new RegularGoblinFactory();
        }

        type        = factory.GetGoblin(gameObject);
        goblinSpeed = type.speed;
    }