Пример #1
0
    private void DisplayMap()
    {
        foreach (Unit u in map.Units)
        {
            if (u.GetType() == typeof(MeeleeUnit))
            {
                MeeleeUnit m = (MeeleeUnit)u;

                if (m.faction == 1)
                {
                    GameObject clone = Instantiate(blueMeelee, new Vector2(m.PosX, m.PosY), Quaternion.identity);
                    clone.transform.parent = transform;
                }
                else if (m.faction == 0)
                {
                    GameObject clone = Instantiate(redMeelee, new Vector2(m.PosX, m.PosY), Quaternion.identity);
                    clone.transform.parent = transform;
                }
                else
                {
                    GameObject clone = Instantiate(ground, new Vector2(m.PosX, m.PosY), Quaternion.identity);
                    clone.transform.parent = transform;
                }
                if (m.isDead())
                {
                    GameObject clone = Instantiate(body, new Vector2(m.PosX, m.PosY), Quaternion.identity);
                    clone.transform.parent = transform;
                }
            }
        }
        foreach (Unit u in map.Units)
        {
            if (u.GetType() == typeof(RangedUnit))
            {
                RangedUnit m = (RangedUnit)u;

                if (m.faction == 1)
                {
                    GameObject clone = Instantiate(redRanged, new Vector2(m.PosX, m.PosY), Quaternion.identity);
                    clone.transform.parent = transform;
                }
                else if (m.faction == 0)
                {
                    GameObject clone = Instantiate(blueRanged, new Vector2(m.PosX, m.PosY), Quaternion.identity);
                    clone.transform.parent = transform;
                }
                else
                {
                    GameObject clone = Instantiate(ground, new Vector2(m.PosX, m.PosY), Quaternion.identity);
                    clone.transform.parent = transform;
                }
                if (m.isDead())
                {
                    GameObject clone = Instantiate(body, new Vector2(m.PosX, m.PosY), Quaternion.identity);
                    clone.transform.parent = transform;
                }
            }
        }

        foreach (Unit u in map.Units)
        {
            if (u.GetType() == typeof(WarlockUnit))
            {
                WarlockUnit w = (WarlockUnit)u;

                if (w.faction == 1)
                {
                    GameObject clone = Instantiate(redWarlock, new Vector2(m.PosX, m.PosY), Quaternion.identity);
                    clone.transform.parent = transform;
                }
                else
                {
                    GameObject clone = Instantiate(blueWarlock, new Vector2(m.PosX, m.PosY), Quaternion.identity);
                    clone.transform.parent = transform;
                }
                if (w.isDead())
                {
                    GameObject clone = Instantiate(body, new Vector2(m.PosX, m.PosY), Quaternion.identity);
                    clone.transform.parent = transform;
                }
            }
        }

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

                if (m.faction == 1)
                {
                    GameObject clone = Instantiate(redFactory, new Vector2(m.PosX, m.PosY), Quaternion.identity);
                    clone.transform.parent = transform;
                }
                else
                {
                    GameObject clone = Instantiate(blueFactory, new Vector2(m.PosX, m.PosY), Quaternion.identity);
                    clone.transform.parent = transform;
                }
                if (m.isDead())
                {
                    GameObject clone = Instantiate(body, new Vector2(m.PosX, m.PosY), Quaternion.identity);
                    clone.transform.parent = transform;
                }
            }
        }

        foreach (Building b in map.Buildings)
        {
            if (b.GetType() == typeof(ResourceBuilding))
            {
                ResourceBuilding m = (ResourceBuilding)b;

                if (m.faction == 1)
                {
                    GameObject clone = Instantiate(redBuilding, new Vector2(m.PosX, m.PosY), Quaternion.identity);
                    clone.transform.parent = transform;
                }
                else
                {
                    GameObject clone = Instantiate(blueBuilding, new Vector2(m.PosX, m.PosY), Quaternion.identity);
                    clone.transform.parent = transform;
                }
                if (m.isDead())
                {
                    GameObject clone = Instantiate(body, new Vector2(m.PosX, m.PosY), Quaternion.identity);
                    clone.transform.parent = transform;
                }
            }
        }
    }
Пример #2
0
    public void DisplayMap()
    {
        foreach (Unit u in map.Units)
        {
            if (u.GetType() == typeof(MeleeUnit))
            {
                int       start_x = 20;
                int       start_Y = 20;
                MeleeUnit m       = (MeleeUnit)u;
                if (m.health > 0)
                {
                    if (m.faction == 1)
                    {
                        GameObject dup = Instantiate(RedMelee, new Vector2(m.Xpos, m.Ypos), Quaternion.identity);
                        dup.transform.parent = transform;
                    }
                    else if (m.faction == 0)
                    {
                        GameObject dup = Instantiate(BlueMelee, new Vector2(m.Xpos, m.Ypos), Quaternion.identity);
                        dup.transform.parent = transform;
                    }
                    else
                    {
                        GameObject dup = Instantiate(GreyMelee, new Vector2(m.Xpos, m.Ypos), Quaternion.identity);
                        dup.transform.parent = transform;
                    }
                }
                if (m.isDead())
                {
                    m.symbol = "X";
                    if (m.faction == 1)
                    {
                        GameObject dup = Instantiate(RedDeath, new Vector2(m.Xpos, m.Ypos), Quaternion.identity);
                        dup.transform.parent = transform;
                    }
                    else if (m.faction == 0)
                    {
                        GameObject dup = Instantiate(BlueDeath, new Vector2(m.Xpos, m.Ypos), Quaternion.identity);
                        dup.transform.parent = transform;
                    }
                    else
                    {
                        GameObject dup = Instantiate(NeutralDeath, new Vector2(m.Xpos, m.Ypos), Quaternion.identity);
                        dup.transform.parent = transform;
                    }
                }
            }
        }

        foreach (Unit u in map.Units)
        {
            if (u.GetType() == typeof(RangedUnit))
            {
                int        start_x = 20;
                int        start_Y = 20;
                RangedUnit m       = (RangedUnit)u;
                if (m.health > 0)
                {
                    if (m.faction == 1)
                    {
                        GameObject dup = Instantiate(RedRanged, new Vector2(m.Xpos, m.Ypos), Quaternion.identity);
                        dup.transform.parent = transform;
                    }
                    else if (m.faction == 0)
                    {
                        GameObject dup = Instantiate(BlueRanged, new Vector2(m.Xpos, m.Ypos), Quaternion.identity);
                        dup.transform.parent = transform;
                    }
                    else
                    {
                        GameObject dup = Instantiate(GreyRanged, new Vector2(m.Xpos, m.Ypos), Quaternion.identity);
                        dup.transform.parent = transform;
                    }
                }
                if (m.isDead())
                {
                    m.symbol = "X";
                    if (m.faction == 1)
                    {
                        GameObject dup = Instantiate(RedDeath, new Vector2(m.Xpos, m.Ypos), Quaternion.identity);
                        dup.transform.parent = transform;
                    }
                    else if (m.faction == 0)
                    {
                        GameObject dup = Instantiate(BlueDeath, new Vector2(m.Xpos, m.Ypos), Quaternion.identity);
                        dup.transform.parent = transform;
                    }
                    else
                    {
                        GameObject dup = Instantiate(NeutralDeath, new Vector2(m.Xpos, m.Ypos), Quaternion.identity);
                        dup.transform.parent = transform;
                    }
                }
            }
        }

        foreach (Unit u in map.Units)
        {
            if (u.GetType() == typeof(WizardUnit))
            {
                int        start_x = 20;
                int        start_Y = 20;
                WizardUnit m       = (WizardUnit)u;
                if (m.health > 0)
                {
                    if (m.faction == 1)
                    {
                        GameObject dup = Instantiate(RedWizard, new Vector2(m.Xpos, m.Ypos), Quaternion.identity);
                        dup.transform.parent = transform;
                    }
                    else if (m.faction == 0)
                    {
                        GameObject dup = Instantiate(BlueWizard, new Vector2(m.Xpos, m.Ypos), Quaternion.identity);
                        dup.transform.parent = transform;
                    }
                }
                if (m.isDead())
                {
                    m.symbol = "X";
                    if (m.faction == 1)
                    {
                        GameObject dup = Instantiate(RedDeath, new Vector2(m.Xpos, m.Ypos), Quaternion.identity);
                        dup.transform.parent = transform;
                    }
                    else if (m.faction == 0)
                    {
                        GameObject dup = Instantiate(BlueDeath, new Vector2(m.Xpos, m.Ypos), Quaternion.identity);
                        dup.transform.parent = transform;
                    }
                }
            }
        }

        foreach (Building u in map.Buildings)
        {
            if (u.GetType() == typeof(FactoryBuilding))
            {
                int             start_x = 20;
                int             start_Y = 20;
                FactoryBuilding m       = (FactoryBuilding)u;
                if (m.health > 0)
                {
                    if (m.faction == 1)
                    {
                        GameObject dup = Instantiate(RedFactory, new Vector2(m.Xpos, m.Ypos), Quaternion.identity);
                        dup.transform.parent = transform;
                    }
                    else if (m.faction == 0)
                    {
                        GameObject dup = Instantiate(BlueFactory, new Vector2(m.Xpos, m.Ypos), Quaternion.identity);
                        dup.transform.parent = transform;
                    }
                }
                if (m.isDead())
                {
                    m.symbol = "X";
                    if (m.faction == 1)
                    {
                        GameObject dup = Instantiate(RedDeath, new Vector2(m.Xpos, m.Ypos), Quaternion.identity);
                        dup.transform.parent = transform;
                    }
                    else if (m.faction == 0)
                    {
                        GameObject dup = Instantiate(BlueDeath, new Vector2(m.Xpos, m.Ypos), Quaternion.identity);
                        dup.transform.parent = transform;
                    }
                }
            }
        }

        foreach (Building u in map.Buildings)
        {
            if (u.GetType() == typeof(ResourceBuilding))
            {
                int start_x        = 20;
                int start_Y        = 20;
                ResourceBuilding m = (ResourceBuilding)u;
                if (m.health > 0)
                {
                    if (m.faction == 1)
                    {
                        GameObject dup = Instantiate(RedMine, new Vector2(m.Xpos, m.Ypos), Quaternion.identity);
                        dup.transform.parent = transform;
                    }
                    else if (m.faction == 0)
                    {
                        GameObject dup = Instantiate(BlueMine, new Vector2(m.Xpos, m.Ypos), Quaternion.identity);
                        dup.transform.parent = transform;
                    }
                }
                if (m.isDead())
                {
                    m.symbol = "X";
                    if (m.faction == 1)
                    {
                        GameObject dup = Instantiate(RedDeath, new Vector2(m.Xpos, m.Ypos), Quaternion.identity);
                        dup.transform.parent = transform;
                    }
                    else if (m.faction == 0)
                    {
                        GameObject dup = Instantiate(BlueDeath, new Vector2(m.Xpos, m.Ypos), Quaternion.identity);
                        dup.transform.parent = transform;
                    }
                }
            }
        }
    }