Пример #1
0
    public void DisplayNewObject()
    {
        RaycastHit[] hitsInOrder  = Physics.RaycastAll(Camera.main.ScreenPointToRay(Input.mousePosition)).OrderBy(h => h.distance).ToArray();
        EarthZone    selectedZone = null;

        foreach (RaycastHit hit in hitsInOrder)
        {
            // This hit.point is the point on earth where you clicked
            foreach (EarthZone controlledZone in ControlledZones)
            {
                if (selectedZone == null && hit.collider == controlledZone.GetComponent <Collider>())
                {
                    if (NewObject.GetComponent <ShieldGenerator>() != null && controlledZone.ShieldGenerator != null)
                    {
                        return;
                    }
                    else
                    {
                        selectedZone = controlledZone;
                    }
                }
                else if (selectedZone != null && hit.transform.gameObject == this.gameObject && controlledZone.GetComponent <Collider>().bounds.Contains(hit.point))
                {
                    NewObject.GetComponent <ZoneBuilding>().ParentZone = selectedZone;
                    NewObject.transform.SetParent(controlledZone.transform, true);
                    // Get a point directly above the city away from earth
                    Vector3 awayFromEarth = hit.point - transform.position;
                    // assign the up vector for the city
                    NewObject.transform.up       = awayFromEarth;
                    NewObject.transform.position = hit.point;
                    return;
                }
            }
        }
    }
Пример #2
0
 void Start()
 {
     foreach (GameObject earthZone in GameObject.FindGameObjectsWithTag("Player"))
     {
         EarthZone zone = earthZone.GetComponent <EarthZone>();
         if (zone != null)
         {
             ControlledZones.Add(zone);
         }
     }
     StartCoroutine(GameTimer());
 }
Пример #3
0
 void DisplayMinorCityUpgrades(EarthZone zone, City city)
 {
     //GUI.enabled = zone.MaxPopulation < 1000000;
     //if (GUILayout.Button("Increase Max Population by 50,000", ButtonStyle))
     //{
     //    zone.MaxPopulation += 50000;
     //}
     GUI.enabled = true;
     if (GUILayout.Button("Double Population Regen Rate", ButtonStyle))
     {
         city.PopulationRegenRate *= 2;
     }
 }
Пример #4
0
 void DisplayWeaponUpgrades(EarthZone zone, Weapon weapon)
 {
     GUI.enabled = true;
     if (GUILayout.Button("Increase Weapon Damage", ButtonStyle))
     {
     }
     GUI.enabled = true;
     if (GUILayout.Button("Decrease Recharge/Reload", ButtonStyle))
     {
     }
     GUI.enabled = true;
     if (GUILayout.Button("Boost Firing Range", ButtonStyle))
     {
     }
 }
Пример #5
0
 void Start()
 {
     GameManager    = gameObject.GetComponent <MenuManager>();
     CityRef        = Resources.Load("City");
     LaserTurretRef = Resources.Load("Turret");
     MissileSiloRef = Resources.Load("MissileSilo");
     GeneratorRef   = Resources.Load("Generator");
     //SatelliteRef = Resources.Load("EarthSatellite");
     foreach (GameObject earthZone in GameObject.FindGameObjectsWithTag("Player"))
     {
         EarthZone zone = earthZone.GetComponent <EarthZone>();
         if (zone != null)
         {
             ControlledZones.Add(zone);
         }
     }
 }
Пример #6
0
 void DisplayShieldGeneratorUpgrades(EarthZone zone)
 {
     GUI.enabled = zone.ShieldGenerator.rechargeTime > 1;
     if (GUILayout.Button("Decrease Shield Recharge Time", ButtonStyle))
     {
         zone.ShieldGenerator.ReduceRechargeTime();
     }
     GUI.enabled = zone.ShieldGenerator.ShieldBoost < (zone.MaxShieldHealth / 2);
     if (GUILayout.Button("Boost Shield Strength", ButtonStyle))
     {
         zone.ShieldGenerator.BoostStrength();
     }
     GUI.enabled = zone.ShieldGenerator.shieldRegenRate <= 16;
     if (GUILayout.Button("Double Shield Regen Rate", ButtonStyle))
     {
         zone.ShieldGenerator.DoubleShieldRegenRate();
     }
 }
Пример #7
0
 void Update()
 {
     //previews placement of new building until clicked
     if (PurchasedZoneBuilding != null)
     {
         RaycastHit[] hitsInOrder = Physics.RaycastAll(Camera.main.ScreenPointToRay(Input.mousePosition)).OrderBy(h => h.distance).ToArray();
         foreach (RaycastHit hit in hitsInOrder)
         {
             // This hit.point is the point on earth where the mouse hovers
             if (selectedZone == null && ControlledZoneColliders.Keys.Contains(hit.collider))
             {
                 // This should only be reached once each time the user hovers over a zone
                 //Debug.Log("selected zone");
                 selectedZone = ControlledZoneColliders[hit.collider];
                 PurchasedZoneBuilding.ParentZone = selectedZone;
                 PurchasedZoneBuilding.isActive   = true;
                 // Put it in the coord space of the earthzone
                 PurchasedZoneBuilding.buildingTransform.SetParent(selectedZone.transform, true);
             }
             else if (selectedZone != null && hit.transform.tag == "Earth" && // user is hovering over controlled zone on earth
                      ControlledZoneColliders.FirstOrDefault(key => key.Value == selectedZone).Key.bounds.Contains(hit.point)) // get the collider(key) based on the value(earthzone)
             {
                 //Debug.Log("selecting spot");
                 // assign the up vector for the city so it the top of it faces away from earth and the bottom sits on the planet
                 PurchasedZoneBuilding.buildingTransform.up = hit.point * 2;
                 // set the position of this newly purchased building to the place where the mouse is
                 PurchasedZoneBuilding.buildingTransform.position = hit.point;
                 // If the user clicks while the newly purchased zone building is being displayed
                 if (Input.GetMouseButton(0))
                 {
                     selectedZone.ZoneBuildings.Add(PurchasedZoneBuilding);
                     //SetZoneCollidersEnabled(false);
                     PurchasedZoneBuilding = null;
                     selectedZone          = null;
                     menuManager.ShopPanel.SetActive(true);
                 }
                 return;
             }
         }
     }
 }