Ejemplo n.º 1
0
    void openMenuOnSelection()
    {
        Vector3 tilePosition = cursor.transform.position;
        int     x            = (int)tilePosition.z;
        int     y            = (int)tilePosition.x;

        selectedGO = tms.getUnitAtTile(x, y);

        if (selectedGO != null)
        {
            UnitBehaviour      ub     = selectedGO.GetComponent <UnitBehaviour> ();
            UnitBehaviour.Team myTeam = (UnitBehaviour.Team)tms.currentPlayer;

            if (ub.teamID == myTeam)
            {
                if (ub.remainingActions != 0)
                {
                    loadUnitMenu();
                }
                else
                {
                    changeCursorColor(MyColor.red);
                }
            }
            else
            {
                changeCursorColor(MyColor.red);
            }
        }
        else
        {
            loadGeneralMenu();
        }
    }
Ejemplo n.º 2
0
    void createUnit(int posX, int posZ, UnitBehaviour.Team team, UnitType type = UnitType.Skeleton)
    {
        GameObject unit = null;

        if (type == UnitType.Lich)
        {
            if (team == UnitBehaviour.Team.Player)
            {
                unit = Instantiate(lichCyan, new Vector3(posX, 0f, posZ), Quaternion.identity) as GameObject;
            }
            else if (team == UnitBehaviour.Team.Enemy1)
            {
                unit = Instantiate(lichRed, new Vector3(posX, 0f, posZ), Quaternion.identity) as GameObject;
            }
            else
            {
                unit = Instantiate(lichNone, new Vector3(posX, 0f, posZ), Quaternion.identity) as GameObject;
            }

            unit.GetComponent <UnitBehaviour> ().SetupStats(posX, posZ, team, 10, 100, 0, 0, 0, 3, 3);
            unit.GetComponent <UnitBehaviour> ().SetupBaseAttack(4, 3, 2);
            unit.transform.localScale = new Vector3(unit.transform.localScale.x * 0.3f, unit.transform.localScale.y * 0.3f, unit.transform.localScale.z * 0.3f);

            if (team == UnitBehaviour.Team.Player && playerLichScript == null)
            {
                playerLichScript = unit.GetComponent <UnitBehaviour> ();
            }
        }
        else if (type == UnitType.Skeleton)
        {
            if (team == UnitBehaviour.Team.Player)
            {
                unit = Instantiate(skeletonCyan, new Vector3(posX, 0f, posZ), Quaternion.identity) as GameObject;
            }
            else if (team == UnitBehaviour.Team.Enemy1)
            {
                unit = Instantiate(skeletonRed, new Vector3(posX, 0f, posZ), Quaternion.identity) as GameObject;
            }
            else
            {
                unit = Instantiate(skeletonNone, new Vector3(posX, 0f, posZ), Quaternion.identity) as GameObject;
            }

            unit.GetComponent <UnitBehaviour> ().SetupStats(posX, posZ, team);
            unit.transform.localScale = new Vector3(unit.transform.localScale.x * 0.3f, unit.transform.localScale.y * 0.3f, unit.transform.localScale.z * 0.3f);
        }
        else if (type == UnitType.Archer)
        {
            if (team == UnitBehaviour.Team.Player)
            {
                unit = Instantiate(archerCyan, new Vector3(posX, 0f, posZ), Quaternion.identity) as GameObject;
            }
            else if (team == UnitBehaviour.Team.Enemy1)
            {
                unit = Instantiate(archerRed, new Vector3(posX, 0f, posZ), Quaternion.identity) as GameObject;
            }
            else
            {
                unit = Instantiate(archerNone, new Vector3(posX, 0f, posZ), Quaternion.identity) as GameObject;
            }

            unit.GetComponent <UnitBehaviour> ().SetupStats(posX, posZ, team, 2, 80, 10, 15, 5, 7, 1);
            unit.GetComponent <UnitBehaviour> ().SetupBaseAttack(5, 2);
        }
        else if (type == UnitType.Imp)
        {
            if (team == UnitBehaviour.Team.Player)
            {
                unit = Instantiate(impCyan, new Vector3(posX, 0f, posZ), Quaternion.identity) as GameObject;
            }
            else if (team == UnitBehaviour.Team.Enemy1)
            {
                unit = Instantiate(impRed, new Vector3(posX, 0f, posZ), Quaternion.identity) as GameObject;
            }
            else
            {
                unit = Instantiate(impNone, new Vector3(posX, 0f, posZ), Quaternion.identity) as GameObject;
            }

            unit.GetComponent <UnitBehaviour> ().SetupStats(posX, posZ, team, 2, 30, 10, 30, 15, 10, 2);
        }
        else if (type == UnitType.Zombie)
        {
            if (team == UnitBehaviour.Team.Player)
            {
                unit = Instantiate(zombieCyan, new Vector3(posX, 0f, posZ), Quaternion.identity) as GameObject;
            }
            else if (team == UnitBehaviour.Team.Enemy1)
            {
                unit = Instantiate(zombieRed, new Vector3(posX, 0f, posZ), Quaternion.identity) as GameObject;
            }
            else
            {
                unit = Instantiate(zombieNone, new Vector3(posX, 0f, posZ), Quaternion.identity) as GameObject;
            }

            unit.GetComponent <UnitBehaviour> ().SetupStats(posX, posZ, team);
        }

        unitsByMap[posZ, posX] = unit;
        Color color = new Color(Random.value, Random.value, Random.value);

        if (team == UnitBehaviour.Team.Player)
        {
            teamPlayer.Add(unit);
        }
        else if (team == UnitBehaviour.Team.Enemy1)
        {
            unit.transform.Rotate(new Vector3(0, 180, 0));
            teamEnemy1.Add(unit);
        }
    }