Esempio n. 1
0
        void UpdateAmmoCount()
        {
            int total   = FPSControl.GetTotalAmmoCount();
            int current = FPSControl.GetCurrentAmmoCount();

            txtAmmo.text = current + "/" + total;
        }
Esempio n. 2
0
        public void OnPauseButton()
        {
            if (FPSControl.IsOn())
            {
                return;
            }

            _GameState gameState = GameControl.GetGameState();

            if (gameState == _GameState.Over)
            {
                return;
            }

            if (toggleFastForward.isOn)
            {
                toggleFastForward.isOn = false;
            }

            if (gameState == _GameState.Pause)
            {
                GameControl.ResumeGame();
                UIPauseMenu.Hide();
            }
            else
            {
                GameControl.PauseGame();
                UIPauseMenu.Show();
            }
        }
Esempio n. 3
0
        // Update is called once per frame
        void Update()
        {
            float value = FPSControl.GetRecoilModifier();

            value = Mathf.Min(value * 25, 250);
            rectRecticleSpread.sizeDelta = new Vector2(150, 150) + new Vector2(value, value) * 2;
        }
Esempio n. 4
0
        void OnSwitchWeapon()
        {
            UpdateAmmoCount();
            reloading = false;

            Sprite weapIcon = FPSControl.GetCurrentWeaponIcon();

            spriteWeaponIcon.sprite = weapIcon;
        }
Esempio n. 5
0
        public void _Hide()
        {
            if (UI.UseDragNDrop() && !FPSControl.IsOn())
            {
                return;
            }

            BuildManager.ClearBuildPoint();

            isOn = false;
            thisObj.SetActive(isOn);
        }
Esempio n. 6
0
        public IEnumerator ReloadRoutine()
        {
            FPSControl.StartReload(this);

            reloadDuration = GetReloadDuration();
            while (reloadDuration > 0)
            {
                reloadDuration -= Time.deltaTime;
                yield return(null);
            }
            currentAmmo = GetClipSize();

            FPSControl.ReloadComplete(this);
        }
Esempio n. 7
0
        //public GameObject FPSModeCrosshairObj;
        public void OnFPSModeButton()
        {
            if (selectedTower == null)
            {
                return;
            }

            Vector3 pos = selectedTower.thisT.position + new Vector3(0, 7, 0);

            FPSControl.SetAnchorTower(selectedTower);
            ClearSelectedTower();

            FPSControl.Show(pos);
            //FPSModeCrosshairObj.SetActive(true);
        }
Esempio n. 8
0
        public void ToggleFF()
        {
            if (FPSControl.IsOn())
            {
                return;
            }

            if (toggleFastForward.isOn)
            {
                Time.timeScale = UI.GetFFTime();
            }
            else
            {
                Time.timeScale = 1;
            }
        }
Esempio n. 9
0
        void Awake()
        {
            instance = this;
            thisObj  = gameObject;
            thisT    = transform;

            camMain = Camera.main;
            camFPS  = camT.GetComponent <Camera>();

            recoilMode = Mathf.Clamp(recoilMode, 0, 2);
            if (recoilMode == 2)
            {
                weaponPivot.parent = camT;
            }

            InitWeapon();
        }
Esempio n. 10
0
        // Update is called once per frame
        void Update()
        {
            if (GameControl.GetGameState() == _GameState.Over)
            {
                return;
            }

            if (FPSControl.IsOn())
            {
                return;
            }

            if (abilityTargetSelecting)
            {
                return;
            }

                        #if UNITY_IPHONE || UNITY_ANDROID || UNITY_WP8
            if (Input.touchCount == 1)
            {
                Touch touch = Input.touches[0];

                if (UIUtilities.IsCursorOnUI(touch.fingerId))
                {
                    return;
                }

                if (!UseDragNDrop() && !UIBuildButton.isOn)
                {
                    BuildManager.SetIndicator(touch.position);
                }

                if (touch.phase == TouchPhase.Began)
                {
                    OnTouchCursorDown(touch.position);
                }
            }
            else
            {
                UpdateMouse();
            }
                        #else
            UpdateMouse();
                        #endif
        }
Esempio n. 11
0
        void Awake()
        {
            instance = (FPSControl)target;

            GetWeapon();

            //EditorUtility.SetDirty(instance);

            recoilModeLabel   = new string[3];
            recoilModeTooltip = new string[3];

            recoilModeLabel[0] = "None";
            recoilModeLabel[1] = "Mode1 (simulated spread)";
            recoilModeLabel[2] = "Mode2 (actual recoil)";

            recoilModeTooltip[0] = "No recoil";
            recoilModeTooltip[1] = "The aims remains in place but the bullet is stray from the aim direction. The bullet spreading will auto-correct back to the aim.";
            recoilModeTooltip[2] = "The aims recoil and require user input to manually correct the aim";
        }
Esempio n. 12
0
        public string _PurchasePerk(Perk perk, bool useRsc = true)
        {
            string text = perk.Purchase(useRsc);

            if (text != "")
            {
                return(text);
            }

            if (onPerkPurchasedE != null)
            {
                onPerkPurchasedE(perk);
            }

            //process the prereq for other perk
            for (int i = 0; i < perkList.Count; i++)
            {
                Perk perkTemp = perkList[i];
                if (perkTemp.purchased || perkTemp.prereq.Count == 0)
                {
                    continue;
                }
                perkTemp.prereq.Remove(perk.ID);
            }


            perkPoint += 1;
            if (onPerkPointE != null)
            {
                onPerkPointE(perkPoint);
            }

            if (perk.type == _PerkType.NewTower)
            {
                List <UnitTower> towerList = TowerDB.Load();
                for (int i = 0; i < towerList.Count; i++)
                {
                    if (towerList[i].prefabID == perk.itemIDList[0])
                    {
                        unlockedTower.Add(towerList[i]);
                        BuildManager.AddNewTower(towerList[i]);
                    }
                }
            }
            else if (perk.type == _PerkType.NewAbility)
            {
                List <Ability> abilityList = AbilityDB.Load();
                for (int i = 0; i < abilityList.Count; i++)
                {
                    if (abilityList[i].ID == perk.itemIDList[0])
                    {
                        unlockedAbility.Add(abilityList[i]);
                        AbilityManager.AddNewAbility(abilityList[i]);
                    }
                }
            }
            else if (perk.type == _PerkType.NewFPSWeapon)
            {
                List <FPSWeapon> FPSWeaponList = FPSWeaponDB.Load();
                for (int i = 0; i < FPSWeaponList.Count; i++)
                {
                    if (FPSWeaponList[i].prefabID == perk.itemIDList[0])
                    {
                        unlockedWeapon.Add(FPSWeaponList[i]);
                        FPSControl.AddNewWeapon(FPSWeaponList[i]);
                    }
                }
            }

            else if (perk.type == _PerkType.GainLife)
            {
                GameControl.GainLife((int)Random.Range(perk.value, perk.valueAlt));
            }
            else if (perk.type == _PerkType.LifeCap)
            {
                lifeCap += (int)perk.value; GameControl.GainLife(0);
            }
            else if (perk.type == _PerkType.LifeRegen)
            {
                lifeRegen += perk.value;
            }
            else if (perk.type == _PerkType.LifeWaveClearedBonus)
            {
                lifeWaveClearedBonus += (int)perk.value;
            }

            else if (perk.type == _PerkType.GainRsc)
            {
                List <int> valueList = new List <int>();
                for (int i = 0; i < perk.valueRscList.Count; i++)
                {
                    valueList.Add((int)perk.valueRscList[i]);
                }
                ResourceManager.GainResource(valueList, null, false);                   //dont pass multiplier and dont use multiplier
            }
            else if (perk.type == _PerkType.RscRegen)
            {
                for (int i = 0; i < perk.valueRscList.Count; i++)
                {
                    rscRegen[i] += perk.valueRscList[i];
                }
            }
            else if (perk.type == _PerkType.RscGain)
            {
                for (int i = 0; i < perk.valueRscList.Count; i++)
                {
                    rscGain[i] += perk.valueRscList[i];
                }
            }
            else if (perk.type == _PerkType.RscCreepKilledGain)
            {
                for (int i = 0; i < perk.valueRscList.Count; i++)
                {
                    rscCreepKilledGain[i] += perk.valueRscList[i];
                }
            }
            else if (perk.type == _PerkType.RscWaveClearedGain)
            {
                for (int i = 0; i < perk.valueRscList.Count; i++)
                {
                    rscWaveClearedGain[i] += perk.valueRscList[i];
                }
            }
            else if (perk.type == _PerkType.RscResourceTowerGain)
            {
                for (int i = 0; i < perk.valueRscList.Count; i++)
                {
                    rscRscTowerGain[i] += perk.valueRscList[i];
                }
            }

            else if (perk.type == _PerkType.Tower)
            {
                ModifyTowerModifier(globalTowerModifier, perk);
            }
            else if (perk.type == _PerkType.TowerSpecific)
            {
                for (int i = 0; i < perk.itemIDList.Count; i++)
                {
                    int ID = TowerModifierExist(perk.itemIDList[i]);
                    if (ID == -1)
                    {
                        PerkTowerModifier towerModifier = new PerkTowerModifier();
                        towerModifier.prefabID = perk.itemIDList[i];
                        towerModifierList.Add(towerModifier);
                        ID = towerModifierList.Count - 1;
                    }
                    ModifyTowerModifierInList(ID, perk);
                }
            }
            else if (perk.type == _PerkType.Ability)
            {
                ModifyAbilityModifier(globalAbilityModifier, perk);
            }
            else if (perk.type == _PerkType.AbilitySpecific)
            {
                for (int i = 0; i < perk.itemIDList.Count; i++)
                {
                    int ID = AbilityModifierExist(perk.itemIDList[i]);
                    if (ID == -1)
                    {
                        PerkAbilityModifier abilityModifier = new PerkAbilityModifier();
                        abilityModifier.abilityID = perk.itemIDList[i];
                        abilityModifierList.Add(abilityModifier);
                        ID = abilityModifierList.Count - 1;
                    }
                    ModifyAbilityModifierInList(ID, perk);
                }
            }
            else if (perk.type == _PerkType.FPSWeapon)
            {
                ModifyFPSWeaponModifier(globalFPSWeaponModifier, perk);
            }
            else if (perk.type == _PerkType.FPSWeaponSpecific)
            {
                for (int i = 0; i < perk.itemIDList.Count; i++)
                {
                    int ID = FPSWeaponModifierExist(perk.itemIDList[i]);
                    if (ID == -1)
                    {
                        PerkFPSWeaponModifier weaponModifier = new PerkFPSWeaponModifier();
                        weaponModifier.prefabID = perk.itemIDList[i];
                        FPSWeaponModifierList.Add(weaponModifier);
                        ID = FPSWeaponModifierList.Count - 1;
                    }
                    ModifyFPSWeaponModifierInList(ID, perk);
                }
            }

            else if (perk.type == _PerkType.EnergyRegen)
            {
                energyRegen += perk.value;
            }
            else if (perk.type == _PerkType.EnergyIncreaseCap)
            {
                energyCap += perk.value;
            }
            else if (perk.type == _PerkType.EnergyCreepKilledBonus)
            {
                energyCreepKilledBonus += perk.value;
            }
            else if (perk.type == _PerkType.EnergyWaveClearedBonus)
            {
                energyWaveClearedBonus += perk.value;
            }

            return("");
        }
Esempio n. 13
0
 void OnDestroy()
 {
     instance = null;
 }
Esempio n. 14
0
        public void _Show(UnitTower tower, bool showControl = false)
        {
            if (!tower.IsTower())
            {
                return;
            }

            isOn = true;

            thisObj.SetActive(showControl);
            floatingButtons.SetActive(showControl);
            controlObj.SetActive(showControl);
            rscObj.SetActive(!showControl);

            currentTower = tower;

            if (showControl)
            {
                if (currentTower.IsInConstruction())
                {
                    StartCoroutine(WaitForConstruction());
                    floatingButtons.SetActive(false);
                }

                upgradeOption = currentTower.ReadyToBeUpgrade();
                if (upgradeOption > 0)
                {
                    butUpgrade.SetActive(true);
                    if (upgradeOption > 1)
                    {
                        butUpgradeAlt1.SetActive(true);
                    }
                    else
                    {
                        butUpgradeAlt1.SetActive(false);
                    }
                }
                else
                {
                    butUpgrade.SetActive(false);
                    butUpgradeAlt1.SetActive(false);
                }

                txtTargetPriority.text = tower.targetPriority.ToString();
                if (tower.directionalTargeting)
                {
                    directionObj.SetActive(true);
                    sliderDirection.value = tower.dirScanAngle;
                }
                else
                {
                    directionObj.SetActive(false);
                }

                if (FPSControl.ActiveInScene())
                {
                    if (FPSControl.UseTowerWeapon() && currentTower.FPSWeaponID == -1)
                    {
                        fpsButtonObj.SetActive(false);
                    }
                    else
                    {
                        fpsButtonObj.SetActive(true);
                    }
                }
                else
                {
                    fpsButtonObj.SetActive(false);
                }
            }
            else
            {
                List <int> cost = currentTower.GetCost();
                for (int i = 0; i < rscObjList.Count; i++)
                {
                    rscObjList[i].label.text = cost[i].ToString();
                }
            }

            Update();

            txtName.text  = tower.unitName;
            txtLvl.text   = "lvl" + tower.GetLevel();
            txtDesp1.text = tower.GetDespStats();
            txtDesp2.text = tower.GetDespGeneral();

            thisObj.SetActive(isOn);
        }