public void TestDead1()
        {
            int       damage = 10, hp = 100;
            ICreature creature = new BasicCreature(null, null, null, damage, hp, null);

            Assert.IsFalse(creature.isDead());
        }
        public void TestPathFinder()
        {
            Graph graph            = new Graph(10, 10);
            Node  startDestinaton  = graph.getNode(1, 1);
            Node  finalDestination = graph.getNode(5, 5);

            System.Diagnostics.Debug.WriteLine(startDestinaton);

            BasicCreature creature = new BasicCreature(startDestinaton, finalDestination, graph, 100, 100, null);
            Mooving       mooving  = (Mooving)creature.getMoovnig();

            mooving.onStart();

            Node lastPosition = null;

            while (lastPosition != creature.getPosition())     //ked sa rovnaju posledny node a aktualny, znamena ze sa uz nehybem dalej
            {
                lastPosition = creature.getPosition();
                //najdi novu poziciu
                mooving.prepare();
                creature.action();
                System.Diagnostics.Debug.WriteLine(creature.getPosition());    //debug vypis noveho nodu
            }
            Assert.AreEqual(finalDestination, creature.getPosition());
        }
Beispiel #3
0
        void MainFormMouseUp(object sender, MouseEventArgs e)
        {
            Node n = graph.getNode(e.X / 10, e.Y / 10);
            Node k = graph.getNode(50, 50);

            if (build_tower)
            {
                g.FillEllipse(Brushes.Red, 50, 50, 20, 20);
                ICollection myCollection = ArrayList.Synchronized(things);
                BasicTower  t1           = new BasicTower(n, graph, 100, 100);

                t1.thinking();
                //t1.action();
                t1.draw(g);

                graph.disableNode(e.X / 10, e.Y / 10);
                lock (myCollection.SyncRoot) {
                    things.Add(t1);
                    Console.WriteLine(things.Count + "DELETE");
                }
                build_tower = false;
            }
            if (build_bug)
            {
                BasicCreature c1 = new BasicCreature(n, k, graph, 100, 100, world);
                build_bug = false;
                things.Add(c1);
                c1.draw(g);
            }

            world.setArray(things);
        }
        public void TestInitialStatus()
        {
            int            damage = 10, hp = 100;
            ThinkingObject creatureThinkigObject = new BasicCreature(null, null, null, damage, hp, null);
            Status         mooving = ((ICreature)creatureThinkigObject).getMoovnig();

            Assert.AreEqual(creatureThinkigObject.presentStatus, mooving);
        }
        public void TestHp()
        {
            int           damage = 10, hp = 100;
            BasicCreature creature = new BasicCreature(null, null, null, damage, hp, null);

            int takenDamage = 50;

            Assert.AreEqual(creature.ReciveDamage(takenDamage), (hp - takenDamage));
        }
        public void TestDead1()
        {
            int       damage = 10, hp = 100;
            Graph     graph            = new Graph(10, 10);
            Node      startDestinaton  = graph.getNode(1, 1);
            Node      finalDestination = graph.getNode(5, 5);
            ICreature creature         = new BasicCreature(startDestinaton, finalDestination, graph, damage, hp, null);

            Assert.IsFalse(creature.isDead());
        }
        public void TestDead3()
        {
            int       damage = 10, hp = 100;
            ICreature creature = new BasicCreature(null, null, null, damage, hp, null);

            int takenDamage = 120;

            creature.ReciveDamage(takenDamage);

            Assert.IsTrue(creature.isDead());
        }
Beispiel #8
0
        public void TestInitialStatus()
        {
            int            damage = 10, hp = 100;
            Graph          graph                 = new Graph(10, 10);
            Node           startDestinaton       = graph.getNode(1, 1);
            Node           finalDestination      = graph.getNode(5, 5);
            ThinkingObject creatureThinkigObject = new BasicCreature(startDestinaton, finalDestination, graph, damage, hp, null);
            Status         mooving               = ((ICreature)creatureThinkigObject).getMoovnig();

            Assert.AreEqual(creatureThinkigObject.presentStatus, mooving);
        }
        public void Node()
        {
            int           x = 0, y = 0, id = 0, terrain = 0;
            Node          startingNode = new Node(id, x, y, terrain);
            int           damage = 10, hp = 100;
            BasicCreature creature = new BasicCreature(startingNode, null, null, damage, hp, null);

            Node actualPosition = creature.Position;

            Assert.AreEqual(actualPosition, startingNode);
        }
        public void TestHp()
        {
            int           damage = 10, hp = 100;
            Graph         graph            = new Graph(10, 10);
            Node          startDestinaton  = graph.getNode(1, 1);
            Node          finalDestination = graph.getNode(5, 5);
            BasicCreature creature         = new BasicCreature(startDestinaton, finalDestination, graph, damage, hp, null);

            int takenDamage = 50;

            Assert.AreEqual(creature.ReciveDamage(takenDamage), (hp - takenDamage));
        }
        public void Node()
        {
            Graph         graph = new Graph(10, 10);
            Node          startDestinaton = graph.getNode(1, 1);
            Node          finalDestination = graph.getNode(5, 5);
            int           damage = 10, hp = 100;
            BasicCreature creature = new BasicCreature(startDestinaton, finalDestination, graph, damage, hp, null);

            Node actualPosition = creature.Position;

            Assert.AreEqual(actualPosition, startDestinaton);
        }
        public void TestMoovingChangeToDying()
        {
            int       damage = 10, hp = 100;
            ICreature creature = new BasicCreature(null, null, null, damage, hp, null);
            Status    mooving  = creature.getMoovnig();
            Status    dying    = creature.getDying();

            int takenDamage = 100;

            creature.ReciveDamage(takenDamage);

            Assert.AreEqual(mooving.changeStatus(), dying);
        }
        public void TestDead3()
        {
            int       damage = 10, hp = 100;
            Graph     graph            = new Graph(10, 10);
            Node      startDestinaton  = graph.getNode(1, 1);
            Node      finalDestination = graph.getNode(5, 5);
            ICreature creature         = new BasicCreature(startDestinaton, finalDestination, graph, damage, hp, null);

            int takenDamage = 120;

            creature.ReciveDamage(takenDamage);

            Assert.IsTrue(creature.isDead());
        }
        public void TestPositionNull()
        {
            int            damage = 10, hp = 100;
            ThinkingObject creatureThinkigObject = new BasicCreature(null, null, null, damage, hp, null);
            Status         mooving = ((ICreature)creatureThinkigObject).getMoovnig();

            try
            {
                mooving.onStart();
            }
            catch (NullReferenceException e)
            {
                StringAssert.Contains(e.Message, Mooving.NULL_POSITION);
            }
        }
        public void TestHp2()
        {
            int           damage = 10, hp = 100;
            BasicCreature creature = new BasicCreature(null, null, null, damage, hp, null);

            try
            {
                int takenDamage = -50;
                creature.ReciveDamage(takenDamage);
            }
            catch (ArgumentOutOfRangeException e)
            {
                StringAssert.Contains(e.Message, BasicCreature.NEGATIVE_DAMAGE);
            }
        }
Beispiel #16
0
        public void TestMoovingChangeToDying()
        {
            int       damage = 10, hp = 100;
            Graph     graph            = new Graph(10, 10);
            Node      startDestinaton  = graph.getNode(1, 1);
            Node      finalDestination = graph.getNode(5, 5);
            ICreature creature         = new BasicCreature(startDestinaton, finalDestination, graph, damage, hp, null);
            Status    mooving          = creature.getMoovnig();
            Status    dying            = creature.getDying();

            int takenDamage = 100;

            creature.ReciveDamage(takenDamage);

            Assert.AreEqual(mooving.changeStatus(), dying);
        }
        public void TestDestinationNull()
        {
            int            x = 0, y = 0, id = 0, terrain = 0;
            Node           startingNode = new Node(id, x, y, terrain);
            int            damage = 10, hp = 100;
            ThinkingObject creatureThinkigObject = new BasicCreature(startingNode, null, null, damage, hp, null);
            Status         mooving               = ((ICreature)creatureThinkigObject).getMoovnig();

            try
            {
                mooving.onStart();
            }
            catch (NullReferenceException e)
            {
                StringAssert.Contains(e.Message, Mooving.NULL_DESTINATION);
            }
        }
        public void TestHp2()
        {
            int           damage = 10, hp = 100;
            Graph         graph            = new Graph(10, 10);
            Node          startDestinaton  = graph.getNode(1, 1);
            Node          finalDestination = graph.getNode(5, 5);
            BasicCreature creature         = new BasicCreature(startDestinaton, finalDestination, graph, damage, hp, null);

            try
            {
                int takenDamage = -50;
                creature.ReciveDamage(takenDamage);
            }
            catch (ArgumentOutOfRangeException e)
            {
                StringAssert.Contains(e.Message, BasicCreature.NEGATIVE_DAMAGE);
            }
        }
Beispiel #19
0
        void Button5Click(object sender, EventArgs e)
        {
            MessageBox.Show("SAVE GAME");
            string content          = "";
            string path             = "../SAVE.txt";
            List <ThinkingObject> w = world.getarrayOfObjectInGame();

            Node[,] nodes = graph.getNodes();

            for (int i = 0; i < nodes.GetLength(0); i++)
            {
                for (int j = 0; j < nodes.GetLength(1); j++)
                {
                    content += (nodes[i, j].getX() / 10).ToString() + " " + (nodes[i, j].getY() / 10).ToString() + " " + nodes[i, j].getTerrain().ToString() + " ";
                }
            }
            content += "\n";

            Console.WriteLine(content);
            for (int i = 0; i < w.Count; i++)
            {
                if (w[i].GetType() == typeof(BasicCreature))
                {
                    BasicCreature c = (BasicCreature)w[i];
                    content += "0 " + (c.getPosition().getX() / 10).ToString() + " " + (c.getPosition().getY() / 10).ToString() + " ";
                }
                else
                {
                    BasicTower c = (BasicTower)w[i];
                    content += "1 " + (c.getPosition().getX() / 10).ToString() + " " + (c.getPosition().getY() / 10).ToString() + " ";
                }
            }

            Console.WriteLine(content);
            File.WriteAllText(path, content);
        }
Beispiel #20
0
 public CaptureStrategy(BasicCreature creature)
 {
     _creature = creature;
 }
 public virtual void init()
 {
     _creature = GetComponent<BasicCreature> ();
     _allStrategy = new Dictionary<StrategysType, AbstractStrategy> ();
 }
Beispiel #22
0
 public StunStrategy(BasicCreature creature, float stunTime)
 {
     _creature = creature;
     __stuneTime = stunTime;
 }
Beispiel #23
0
 public MoveStrategy(BasicCreature creature)
 {
     _creature = creature;
 }
Beispiel #24
0
 public DeafStrategy(BasicCreature creature)
 {
     _creature = creature;
 }