Exemple #1
0
    void MouseOver_Unit(GameObject ourHitObject)
    {
        //Debug.Log("Raycast hit: " + ourHitObject.name );

        if (Input.GetMouseButtonDown(0) && ourHitObject.GetComponentInParent <AirplanBase>().getCountry() == 1)
        {
            // We have click on the unit
            selectedUnit = ourHitObject.GetComponentInParent <AirplanBase>();
            selectedTown = null;

            gameController.setChoosen(selectedUnit, selectedTown);
        }

        if (Input.GetMouseButtonDown(0) && ourHitObject.GetComponentInParent <AirplanBase>().getCountry() != 1 && selectedTown != null)
        {
            // We have click on the unit
            selectedTown.Attack(ourHitObject.GetComponentInParent <AirplanBase>());
        }

        if (Input.GetMouseButtonDown(0) && ourHitObject.GetComponentInParent <AirplanBase>().getCountry() != 1 && selectedUnit != null)
        {
            // We have click on the unit
            selectedUnit.Attack(ourHitObject.GetComponentInParent <AirplanBase>());
        }
    }
Exemple #2
0
    void SpawnNew(int country, int corX, int corY)
    {
        transPref = findUnitPref.GetAirPref(0);
        //Debug.Log (transPref.name);
        //Debug.Log("I put " + name + " in (" + corX + ", " + corY + ") " );
        Transform tr = Instantiate(transPref) as Transform;
        //Debug.Log (tr.name);
        Vector2 gridPos = new Vector2(corX, corY);

        //Debug.Log (CalcWorldPos (gridPos));
        tr.position = CalcWorldPos(gridPos);
        AirplanBase data = tr.GetComponent <TransportAircraft>();

        //Debug.Log (data.name);
        data.setGrid(this);
        data.setCountry(country);
        data.setCoordinate(gridPos);
        //Debug.Log (country);
        //Debug.Log (MapInfo.current.governments [country]);
        //Debug.Log (MapInfo.current.governments [country].getUnits());
        gameController.getGoverment(country).SetUnit(data);
        //UnitsNasive.list.Add (tr.gameObject);
        tr.name = tr.GetComponent <TransportAircraft>().getNameAir() + country;
        MapInfo.current.unitMap [corX, corY] = country * 100 + data.getTypeOfAirplane();
        if (country == 1)
        {
            camStart = CalcWorldPos(gridPos);
        }
    }
 public void BuildTown()
 {
     choosenPlane.gameObject.GetComponent <TransportAircraft> ().putATown();
     choosenPlane   = null;
     choosen.sprite = sprites [3];
     buildTown.SetActive(false);
     planeButtons.SetActive(false);
 }
Exemple #4
0
 public void DeleteUnit(AirplanBase unit)
 {
     //foreach(AirplanBase u in units) {
     //	if (u.GetId () == unit.GetId ()) {
     units.Remove(unit);
     //		break;
     //	}
     //}
 }
Exemple #5
0
    public void Attack(AirplanBase victim)
    {
        Vector2 vCor = victim.getHex();

        if (CouldAttackHere((int)coordinate.x, (int)coordinate.y, (int)vCor.x, (int)vCor.y, radius))
        {
            victim.setHeal(-30);
        }
    }
Exemple #6
0
    void MouseOver_Town(GameObject ourHitObject)
    {
        if (Input.GetMouseButton(0) && ourHitObject.GetComponent <Town> ().GetGovId() == 1)
        {
            selectedTown = ourHitObject.GetComponent <Town> ();
            selectedUnit = null;
            gameController.setChoosen(selectedUnit, selectedTown);
        }

        if (Input.GetMouseButton(0) && ourHitObject.GetComponent <Town> ().GetGovId() != 1 && selectedUnit != null)
        {
            selectedUnit.AttackTown(ourHitObject.GetComponent <Town> ());
        }
    }
Exemple #7
0
    public void Attack(AirplanBase victim)
    {
        Vector2 toGo = victim.getHex();

        if (CurrentAction > 0)
        {
            if (CouldGoThere((int)coordinate.x, (int)coordinate.y, (int)toGo.x, (int)toGo.y, radAttack, false))
            {
                victim.setHeal(-damageForPlane);
                CurrentAction = 0;
                //Debug.Log (victim.getHeal ());
            }
        }
    }
 public void NextStep()
 {
     choosenPlane = null;
     choosenTown  = null;
     mm.setNull();
     buildTown.SetActive(false);
     planeButtons.SetActive(false);
     townProject.SetActive(false);
     MapInfo.current.steps++;
     foreach (GovernmentBase g in goverments)
     {
         //Debug.Log ("foreach of gover " + g.GetName());
         g.NextStepGovernment();
     }
     checkSteps();
 }
Exemple #9
0
 void LoadSpawn(int x, int y)
 {
     transPref = findUnitPref.GetAirPref(MapInfo.current.unitMap[x, y] % 100);
     if (MapInfo.current.unitMap [x, y] != 0)
     {
         Transform tr      = Instantiate(transPref) as Transform;
         Vector2   gridPos = new Vector2(x, y);
         tr.position = CalcWorldPos(gridPos);
         AirplanBase data = tr.GetComponent <AirplanBase>();
         data.setCountry(MapInfo.current.unitMap[x, y] / 100);
         data.setGrid(this);
         data.setCoordinate(gridPos);
         gameController.getGoverment(MapInfo.current.unitMap[x, y] / 100).SetUnit(data);
         //UnitsNasive.list.Add (tr.gameObject);
         tr.name = tr.GetComponent <AirplanBase>().getNameAir() + data.getCountry();
         if (MapInfo.current.unitMap[x, y] / 100 == 1)
         {
             camStart = CalcWorldPos(gridPos);
         }
     }
 }
Exemple #10
0
 public void SetUnit(AirplanBase unit)
 {
     units.Add(unit);
 }
Exemple #11
0
    public void setChoosen(AirplanBase plane, Town town)
    {
        gayMenu.GetParametrs();
        choosenPlane = plane;
        choosenTown  = town;

        if (choosenPlane != null)
        {
            switch (choosenPlane.getTypeOfAirplane())
            {
            case 0:
            case 3:
            case 6:

                choosen.sprite = sprites [0];
                break;

            case 1:
            case 4:
            case 7:

                choosen.sprite = sprites [1];
                break;

            case 2:
            case 5:
            case 8:

                choosen.sprite = sprites [2];
                break;
            }
            checkSteps();
            planeButtons.SetActive(true);
            if (choosenPlane.getTypeOfAirplane() == 0)
            {
                buildTown.SetActive(true);
            }
            else
            {
                buildTown.SetActive(false);
            }
            townProject.SetActive(false);
            switch (choosenPlane.getCountry())
            {
            case 1:
                choosen.color = Color.red;
                break;

            case 2:
                choosen.color = Color.blue;
                break;

            case 3:
                choosen.color = Color.green;
                break;

            case 4:
                choosen.color = Color.yellow;
                break;

            case 5:
                choosen.color = Color.magenta;
                break;

            case 6:
                choosen.color = Color.black;
                break;

            case 7:
                choosen.color = Color.red * Color.yellow;
                break;

            case 8:
                choosen.color = Color.green * Color.red;
                break;

            case 9:
                choosen.color = Color.blue * Color.red;
                break;

            default:
                choosen.color = Color.white;
                break;
            }
        }
        else
        {
            choosen.sprite = sprites [3];
            buildTown.SetActive(false);
            planeButtons.SetActive(false);
            townProject.SetActive(true);
            switch (choosenTown.GetGovId())
            {
            case 1:
                choosen.color = Color.red;
                break;

            case 2:
                choosen.color = Color.blue;
                break;

            case 3:
                choosen.color = Color.green;
                break;

            case 4:
                choosen.color = Color.yellow;
                break;

            case 5:
                choosen.color = Color.magenta;
                break;

            case 6:
                choosen.color = Color.black;
                break;

            case 7:
                choosen.color = Color.red * Color.yellow;
                break;

            case 8:
                choosen.color = Color.green * Color.red;
                break;

            case 9:
                choosen.color = Color.blue * Color.red;
                break;

            default:
                choosen.color = Color.white;
                break;
            }
        }
    }