Esempio n. 1
0
            public void DifficultyRange(SpiderTypes 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             = SpiderFactory.createSpider(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);
            }
Esempio n. 2
0
            public void ClassValidity(SpiderTypes type, Type expected)
            {
                const int DIFF = 1;
                Entity    ent  = SpiderFactory.createSpider(type, DIFF);

                try
                {
                    Convert.ChangeType(ent, expected);
                }
                catch
                {
                    Assert.Fail();
                }
            }
Esempio n. 3
0
    void Update()
    {
        Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);

        if (Input.GetMouseButtonDown(0))
        {
            oldMousePos          = mousePos;
            boxSelector.boxStart = mousePos;
            leftMouse.Execute(mousePos, selectedUnits);
        }

        if (Input.GetMouseButton(0))
        {
            var difference = Vector3.Distance(oldMousePos, mousePos);
            if (difference > 0.05)
            {
                boxSelector.mousePos = mousePos;
                boxSelector.active   = true;
                boxSelector.Select(ref selectedUnits);
            }
        }

        if (Input.GetMouseButtonUp(0))
        {
            boxSelector.active = false;
        }

        if (Input.GetMouseButtonDown(1))
        {
            //GameObject target = new Raycast().Cast(mousePos, Vector3.zero);

            //if (target == null) {
            //    moveCommand.Execute(mousePos, selectedUnits);
            //} else if (target)
            //{
            //    attackCommand.Execute(target, selectedUnits);
            //}
            foreach (var spider in spiderFactory.spidersList.spidersList)
            {
                spider.agent.SetDestination(mousePos);
            }
        }

        if (Input.GetKeyDown(KeyCode.W))
        {
            spiderFactory.createSpider(mousePos);
        }
    }
Esempio n. 4
0
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            RaycastHit hit;
            if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit))
            {
                GameObject hitObject = hit.transform.gameObject;
                selectedUnits.add(hitObject);
            }
        }

        if (Input.GetMouseButtonDown(1))
        {
            RaycastHit hit;
            if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit))
            {
                if (hit.transform.gameObject.GetComponent <HealthComponent>())
                {
                    //Attack Logic
                    foreach (GameObject unit in selectedUnits.selectedUnits)
                    {
                        unit.GetComponent <AttackComponent>().acquireTarget(hit.transform.gameObject);
                    }
                }
                else
                {
                    foreach (GameObject unit in selectedUnits.selectedUnits)
                    {
                        unit.GetComponent <NavigationComponent>().setDestination(hit.point);
                        unit.GetComponent <AttackComponent>().target = null;
                    }
                }
            }
        }

        if (Input.GetKeyDown(KeyCode.W))
        {
            RaycastHit hit;
            if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit))
            {
                spiderFactory.createSpider(hit.point);
            }
        }
    }