예제 #1
0
    public void Clickon()
    {
        Ray          ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit2D hit = Physics2D.Raycast(ray.origin, ray.direction, Mathf.Infinity);

        if (hit)
        {
            float x = hit.collider.transform.position.x;
            float y = hit.collider.transform.position.y;

            foreach (Unit u in map.Unit)
            {
                if (u.GetType() == typeof(RangedUnits))
                {
                    RangedUnits r = (RangedUnits)u;
                    if (r.Xpos == x && r.Ypos == y)
                    {
                        texts.text = r.Tostring();
                    }
                }
                else if (u.GetType() == typeof(MeleeUnit))
                {
                    MeleeUnit m = (MeleeUnit)u;
                    if (m.Xpos == x && m.Ypos == y)
                    {
                        texts.text = m.Tostring();
                    }
                }
            }
            foreach (FactoryBuilding u in map.Building)
            {
                if (u.GetType() == typeof(FactoryBuilding))
                {
                    FactoryBuilding r = (FactoryBuilding)u;
                    if (r.Xpos == x && r.Ypos == y)
                    {
                        texts.text = r.toString();
                    }
                }
                else if (u.GetType() == typeof(FactoryBuilding))
                {
                    FactoryBuilding m = (FactoryBuilding)u;
                    if (m.Xpos == x && m.Ypos == y)
                    {
                        texts.text = m.toString();
                    }
                }
            }
            foreach (ResourceBuilding u in map.RB)
            {
                if (u.GetType() == typeof(ResourceBuilding))
                {
                    ResourceBuilding r = (ResourceBuilding)u;
                    if (r.Xpos == x && r.Ypos == y)
                    {
                        texts.text = r.toString();
                    }
                }
                else if (u.GetType() == typeof(ResourceBuilding))
                {
                    ResourceBuilding m = (ResourceBuilding)u;
                    if (m.Xpos == x && m.Ypos == y)
                    {
                        texts.text = m.toString();
                    }
                }
            }
        }
    }
예제 #2
0
    public void Click()
    {
        int x = map.PosX;
        int Y = map.PosY;

        foreach (Unit u in map.Units)
        {
            if (u.GetType() == typeof(RangedUnit))
            {
                RangedUnit r = (RangedUnit)u;

                if (r.PosX == x && r.PosY == Y)
                {
                    txtTexts.text = "" + m.toString;
                }
            }

            else if (u.GetType() == typeof(MeeleeUnit))
            {
                MeeleeUnit m = (MeeleeUnit)u;

                if (m.PosX == x && m.PosY == Y)
                {
                    txtTexts.text = "" + m.toString();
                }
            }

            else if (u.GetType() == typeof(WarlockUnit))
            {
                WarlockUnit m = (WarlockUnit)u;

                if (m.PosX == x && m.PosY == Y)
                {
                    txtTexts.text = "" + m.toString();
                }
            }
        }

        foreach (Building b in map.Buildings)
        {
            if (b.GetType() == typeof(FactoryBuilding))
            {
                FactoryBuilding fb = (FactoryBuilding)b;

                if (fb.PosX == x && fb.PosY == Y)
                {
                    txtTexts.text = "" + fb.toString();
                }
            }

            else if (b.GetType() == typeof(ResourceBuilding))
            {
                ResourceBuilding rb = (ResourceBuilding)b;

                if (rb.PosX == x && rb.PosY == Y)
                {
                    txtTexts.text = "" + rb.toString();
                }
            }
        }
    }
예제 #3
0
    public void castRay()
    {
        Ray          ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit2D hit = Physics2D.Raycast(ray.origin, ray.direction, Mathf.Infinity);

        if (hit)
        {
            float x = hit.collider.transform.position.x;
            float y = hit.collider.transform.position.y;


            Debug.Log("" + x + " " + y);

            foreach (Unit u in map.Units)
            {
                if (u.GetType() == typeof(RangedUnit))
                {
                    RangedUnit r = (RangedUnit)u;

                    if (r.Xpos == x && r.Ypos == y)
                    {
                        info.text = "" + r.toString();
                    }
                }

                else if (u.GetType() == typeof(MeleeUnit))
                {
                    MeleeUnit m = (MeleeUnit)u;

                    if (m.Xpos == x && m.Ypos == y)
                    {
                        info.text = "" + m.toString();
                    }
                }

                else if (u.GetType() == typeof(WizardUnit))
                {
                    WizardUnit m = (WizardUnit)u;

                    if (m.Xpos == x && m.Ypos == y)
                    {
                        info.text = "" + m.toString();
                    }
                }
            }

            foreach (Building b in map.Buildings)
            {
                if (b.GetType() == typeof(FactoryBuilding))
                {
                    FactoryBuilding fb = (FactoryBuilding)b;

                    if (fb.Xpos == x && fb.Ypos == y)
                    {
                        info.text = "" + fb.toString();
                    }
                }

                else if (b.GetType() == typeof(ResourceBuilding))
                {
                    ResourceBuilding rb = (ResourceBuilding)b;

                    if (rb.Xpos == x && rb.Ypos == y)
                    {
                        info.text = "" + rb.toString();
                    }
                }
            }
        }
    }