void OnSwitchWeapon() { UpdateAmmoCount(); reloading = false; fpsItem.imgRoot.sprite = FPSControl.GetCurrentWeaponIcon(); }
void UpdateAmmoCount() { int total = FPSControl.GetTotalAmmoCount(); int current = FPSControl.GetCurrentAmmoCount(); fpsItem.label.text = current + "/" + total; }
void Awake() { instance = (FPSControl)target; LoadDB(); InitLabel(); }
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(); } }
void UpdateAmmoCount() { int total = FPSControl.GetTotalAmmoCount(); int current = FPSControl.GetCurrentAmmoCount(); txtAmmo.text = current + "/" + total; }
// 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; }
void OnSwitchWeapon() { UpdateAmmoCount(); reloading = false; Sprite weapIcon = FPSControl.GetCurrentWeaponIcon(); spriteWeaponIcon.sprite = weapIcon; }
public void _Hide() { if (UI.UseDragNDrop() && !FPSControl.IsOn()) { return; } BuildManager.ClearBuildPoint(); isOn = false; thisObj.SetActive(isOn); }
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(); }
void Update() { if (FPSControl.IsInFPSMode()) { return; } if (AbilityManager.IsSelectingTarget()) { return; } //if(!disableCursorIndicator) BuildManager.SetTileIndicator(Input.mousePosition); }
public IEnumerator ReloadRoutine() { FPSControl.StartReload(this); reloadDuration = GetReloadDuration(); while (reloadDuration > 0) { reloadDuration -= Time.deltaTime; yield return(null); } currentAmmo = GetClipSize(); FPSControl.ReloadComplete(this); }
//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); }
public void ToggleFF() { if (FPSControl.IsOn()) { return; } if (toggleFastForward.isOn) { Time.timeScale = UI.GetFFTime(); } else { Time.timeScale = 1; } }
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(); }
public void UpdateDisplay() { if (currentTower == null) { return; } lbTowerName.text = currentTower.unitName; lbTowerLevel.text = "lvl" + currentTower.GetLevel(); lbTowerDesp1.text = "damage: " + currentTower.GetDamageMin() + "-" + currentTower.GetDamageMax(); lbTowerDesp1.text = currentTower.GetDespStats(); //"damage: "+currentTower.GetDamageMin()+"-"+currentTower.GetDamageMax(); lbTowerDesp2.text = currentTower.GetDespGeneral(); sliderDrection.value = currentTower.dirScanAngle; directionControlObj.SetActive(currentTower.directionalTargeting); int upgradeOption = currentTower.ReadyToBeUpgrade(); butUpgrade1Canvas.alpha = upgradeOption >= 1 ? 1 : 0; butUpgrade1Canvas.interactable = upgradeOption >= 1 ? true : false; butUpgrade2Canvas.alpha = upgradeOption >= 2 ? 1 : 0; butUpgrade2Canvas.interactable = upgradeOption >= 2 ? true : false; //butUpgradeObj1.SetActive(upgradeOption>=1 ? true : false); //butUpgradeObj2.SetActive(upgradeOption>=2 ? true : false); butSellObj.SetActive(currentTower.canBeSold); bool enableFPS = FPSControl.ActiveInScene(); if (enableFPS && currentTower.disableFPS) { enableFPS = false; } if (enableFPS && FPSControl.UseTowerWeapon() && currentTower.FPSWeaponID == -1) { enableFPS = false; } if (enableFPS && !FPSControl.IsIDAvailable(currentTower.FPSWeaponID)) { enableFPS = false; } butFPSObj.SetActive(enableFPS); }
// 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 }
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"; }
public IEnumerator ReloadRoutine() { FPSControl.StartReload(this); if (reloadSound != null) { AudioManager.PlaySound(reloadSound); } reloadDuration = GetReloadDuration(); while (reloadDuration > 0) { reloadDuration -= Time.deltaTime; yield return(null); } currentAmmo = GetClipSize(); FPSControl.ReloadComplete(this); }
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"; }
public void Init() { 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; } List <FPSWeapon> dbList = TDTK.GetFpsWeaponDBList(); //FPSWeaponDB.Load(); availableIDList = new List <int>(); weaponList = new List <FPSWeapon>(); for (int i = 0; i < dbList.Count; i++) { if (dbList[i].disableInFPSControl) { continue; } if (!unavailableIDList.Contains(dbList[i].prefabID)) { weaponList.Add(dbList[i]); availableIDList.Add(dbList[i].prefabID); } } List <FPSWeapon> newList = PerkManager.GetUnlockedWeaponList(); for (int i = 0; i < newList.Count; i++) { weaponList.Add(newList[i]); } }
public void OnNextWeaponButton() { FPSControl.SelectNextWeapon(); }
public void OnFPSButton() { FPSControl.Show(currentTower); _Hide(); }
public string _PurchasePerk(Perk perk, bool useRsc = true) { string text = perk.Purchase(useRsc); if (text != "") { return(text); } if (!purchasedIDList.Contains(perk.ID)) { purchasedIDList.Add(perk.ID); } SavePurchasedPerk(); TDTK.OnPerkPurchased(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; TDTK.OnPerkPoint(); if (perk.type == _PerkType.NewTower) { UnitTower tower = TDTK.GetDBTower(perk.itemIDList[0]); unlockedTowerList.Add(tower); BuildManager.AddNewTower(tower); } else if (perk.type == _PerkType.NewAbility) { Ability ability = TDTK.GetDBAbility(perk.itemIDList[0]); unlockedAbilityList.Add(ability); AbilityManager.AddNewAbility(ability); } else if (perk.type == _PerkType.NewFPSWeapon) { FPSWeapon weapon = TDTK.GetDBFpsWeapon(perk.itemIDList[0]); unlockedWeaponList.Add(weapon); FPSControl.AddNewWeapon(weapon); } 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(""); }
void OnDestroy() { instance = null; }
void Awake() { Time.fixedDeltaTime = timeStep; instance = this; thisT = transform; ObjectPoolManager.Init(); NodeGenerator nodeGenerator = (NodeGenerator)FindObjectOfType(typeof(NodeGenerator)); if (nodeGenerator != null) { nodeGenerator.Awake(); } PathFinder pathFinder = (PathFinder)FindObjectOfType(typeof(PathFinder)); if (pathFinder != null) { pathFinder.Awake(); } PathTD[] paths = FindObjectsOfType(typeof(PathTD)) as PathTD[]; if (paths.Length > 0) { for (int i = 0; i < paths.Length; i++) { paths[i].Init(); } } TDTK.InitDB(); ResourceManager rscManager = (ResourceManager)FindObjectOfType(typeof(ResourceManager)); if (rscManager != null) { rscManager.Init(); } PerkManager perkManager = (PerkManager)FindObjectOfType(typeof(PerkManager)); if (perkManager != null) { perkManager.Init(); } BuildManager buildManager = (BuildManager)FindObjectOfType(typeof(BuildManager)); if (buildManager != null) { buildManager.Init(); } AbilityManager abilityManager = (AbilityManager)FindObjectOfType(typeof(AbilityManager)); if (abilityManager != null) { abilityManager.Init(); } FPSControl fpsControl = (FPSControl)FindObjectOfType(typeof(FPSControl)); if (fpsControl != null) { fpsControl.Init(); } IndicatorControl indicatorControl = (IndicatorControl)FindObjectOfType(typeof(IndicatorControl)); if (indicatorControl != null) { indicatorControl.Init(); } //if(loadAudioManager){ // Instantiate(Resources.Load("AudioManager", typeof(GameObject))); //} Time.timeScale = 1; }
public void OnFireButton(GameObject butObj) { FPSControl.Fire(); }
void OnDestroy() { instance=null; }
public void _Show(UnitTower tower, bool showControl = false) { 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); }
public void OnReloadButton() { FPSControl.Reload(); }
public void OnPrevWeaponButton() { FPSControl.SelectPrevWeapon(); }
void Update() { float value = FPSControl.GetRecoilModifier(); value = Mathf.Min(value * 20, 250); recticleSpreadRectT.sizeDelta = recticleSpreadDefaultSize + new Vector2(value, value) * 2; if (reloading) { imgReloadProgress.fillAmount = FPSControl.GetReloadProgress(); } if (!FPSControl.EnableInput()) { return; } if (Input.GetKeyDown(KeyCode.R)) { FPSControl.Reload(); } if (Input.GetKeyDown(KeyCode.Q)) { FPSControl.SelectPrevWeapon(); } if (Input.GetKeyDown(KeyCode.E)) { FPSControl.SelectNextWeapon(); } if (Input.GetAxisRaw("Mouse ScrollWheel") != 0 && scrollCD <= 0) { if (Input.GetAxis("Mouse ScrollWheel") > 0) { FPSControl.SelectPrevWeapon(); } else { FPSControl.SelectNextWeapon(); } scrollCD = 0.15f; } scrollCD -= Time.deltaTime; if (!touchMode && (Input.GetKey(KeyCode.Space) || Input.GetMouseButton(0))) { FPSControl.Fire(); } if (touchMode && touchFiring) { FPSControl.Fire(); } if (IsOn() && Input.GetKeyDown(KeyCode.Escape)) { FPSControl.Hide(); } }
public void OnExitFPSButton() { FPSControl.Hide(); }