private void Awake() { _camera = GameObject.FindWithTag("Plan Camera").GetComponent <Camera>(); trap = prefab.GetComponent <TrapBase>(); indicator = GetComponent <RangeIndicator>(); counter.count = initialCount; }
void OpenRangeIndicator() { if (!rangeIndicator) { rangeIndicator = RangeIndicator.CreateRangeIndicator(null, Vector3.zero, false, false).GetComponent <RangeIndicator>(); } rangeIndicator.transform.GetChild(0).GetComponent <Renderer>().material.color = Color.green; }
public void ShowRangeIndicator(float range) { if (this.rangeIndicatorGo == null) { this.rangeIndicatorGo = Instantiate <GameObject>(this.rangeIndicatorPf); this.rangeIndicator = rangeIndicatorGo.GetComponent <RangeIndicator>(); } rangeIndicator.Show(range); }
/// <summary> /// Hide Range Indicator /// </summary> public void CancelRangeIndicator() { if (CurrentRangeIndicator != null) { CurrentRangeIndicator.OnHide(); CurrentRangeIndicator.gameObject.SetActive(false); CurrentRangeIndicator = null; } }
RangeIndicator rangeIndicator; //Objet d'affichage de la portee //Initialise une tour a l'aide de sa base et de son arme public void Initialize(TowerBase towerBase, TowerWeapon towerWeapon) { TowerBase = towerBase; //Reference la base this.towerWeapon = towerWeapon; //Reference l'arme rangeIndicator = GetComponentInChildren <RangeIndicator>(); //Reference l'objet de portee rangeIndicator.SetRange(towerWeapon.TowerRange); //Met a jour la portee towerBase.associatedTower = this; //Se definit comme tour de la base en entree towerWeapon.associatedTower = this; //Se definit comme tour de l'arme en entree }
private void Awake() { worldObject = GetComponentInParent <WorldObject>(); selectionIndicatorHalo = GetComponentInChildren <SelectionIndicatorHalo>(true); //selectionIndicatorOrb = GetComponentInChildren<SelectionIndicatorOrb> (true); rangeIndicator = GetComponentInChildren <RangeIndicator>(true); selector = GetComponentInChildren <Selector>(); selectorWhenUp = GetComponentInChildren <SelectorWhenUp>(); selectorWhenDown = GetComponentInChildren <SelectorWhenDown>(); }
void Start() { cur = this; camDepth = Camera.main.transform.position.z; if (Game.currentScene != Scene.BattlefieldEditor) { rangeIndicator = RangeIndicator.CreateRangeIndicator(null, Vector3.zero, false, false).GetComponent <RangeIndicator> (); rangeIndicatorMaterial = rangeIndicator.transform.GetChild(0).GetComponent <Renderer> ().material; } flushTimer = 0; }
public void Init(Player player, float growRate, Vector3 expPt) { this.player = player; this.growRate = growRate; mDamage = Mathf.Lerp(damage.x, damage.y, growRate); mSplashRad = Mathf.Lerp(splashRad.x, splashRad.y, growRate); spawnHeight = transform.position.y; rIndicator = Instantiate(rangeIndicatorPrefab, expPt, Quaternion.identity).GetComponent <RangeIndicator>(); rIndicator.Init(mSplashRad, Color.red, 360); rIndicator.gameObject.SetActive(true); StartCoroutine(IE_PlayFallingSound(Mathf.Lerp(0, 2.0f, growRate))); }
/// <summary> /// Select and make visible the Range Indicator given by name. /// </summary> public void SelectRangeIndicator(string splatName) { CancelRangeIndicator(); RangeIndicator indicator = GetRangeIndicator(splatName); // If current spell indicator uses same Range indicator then cancel it. if (CurrentSpellIndicator != null && CurrentSpellIndicator.RangeIndicator == indicator) { CancelSpellIndicator(); } indicator.gameObject.SetActive(true); indicator.OnShow(); CurrentRangeIndicator = indicator; }
public override void Start() { base.Start(); SetupModels(); rIndicator = GetComponentInChildren <RangeIndicator>(); rIndicator.Init(rIndicatorMaxRad.x, Color.red, 360); rIndicator.gameObject.SetActive(false); camShaker = Camera.main.GetComponent <CameraShakeSimpleScript>(); followCamera.transform.Rotate(camRotOffset); camFollowPt = transform.position + camPosOffset; followCamera.transform.position = camFollowPt; sk2Button.Active(false); sk3Button.Active(false); }
void OnEnable() { var t = GetComponent <TowerInfo>(); if (t.type == TowerType.VisionTower) { range = t.vision; } else { range = t.range; } indicator = GetComponent <RangeIndicator>(); curPosition = transform.position; UpdateRange(); indicator.enabled = false; }
public static void Open(Vector3 position, Module _module) { if (cur) { Close(); cur.module = _module; cur.gameObject.SetActive(true); cur.transform.position = (Vector2)position; for (int i = 0; i < cur.buttons.Length; i++) { cur.buttons[i].transform.position = cur.transform.position; cur.buttons[i].transform.localScale = Vector3.zero; } cur.StartCoroutine(cur.Animate()); cur.UpdateHoverContextElements(); cur.rangeIndicator = RangeIndicator.CreateRangeIndicator(cur.module.gameObject, cur.module.transform.position, true, false).GetComponent <RangeIndicator> (); cur.rangeIndicator.GetComponentInChildren <SpriteRenderer> ().color = Color.green; cur.rangeIndicator.GetRange(cur.module.GetRange()); UpdateButtons(); } }
void UpdateRangeIndicator() { indicatorRange = 0f; RangeIndicator.ForceRequestRange(rootModule.gameObject, gameObject); rangeIndicator.transform.position = rootModule.transform.position; if (rootModule.moduleType == Module.Type.Weapon) { if (rootModule.parentBase) { rangeIndicator.GetRange(rootModule.parentBase.GetRange() * indicatorRange); } else { rangeIndicator.GetRange(indicatorRange * WeaponModule.indieRange); } } else { rangeIndicator.GetRange(indicatorRange); } }
// Update is called once per frame void Update() { // Grap mouse position, and round it. worldMousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); pos = RoundPos(worldMousePos, pModule ? pModule.moduleClass : 1); if (rangeIndicator) { rangeIndicator.GetRange(0f); } if (Input.GetButtonDown("Cancel")) { bool isPaused = Game.isPaused; bool anyActive = Game.AnyActiveAboveOverlay(); if (isPaused) { Game.game.TogglePause(); } if (!CancelAll()) { CloseAllWindows(); if (!anyActive && !isPaused) { Game.game.TogglePause(); } } } if (isPlacing && !isEditingWalls && Game.currentScene != Scene.BattlefieldEditor) { rangeIndicator.transform.position = placementParent.position; if (!isRotting) { placePos = new Vector3(pos.x, pos.y, 0f); placeRot = Quaternion.Euler(0, 0, 90f); } UpdatePlacementSprite(); GetHitModule(); indicatorRange = 0f; RangeIndicator.ForceRequestRange(activePurchaseCopy, gameObject); if (hitModule) { placeRot = hitModule.transform.rotation; if (hitModule.moduleType == Module.Type.Weapon || hitModule.moduleType == Module.Type.Independent) { rangeIndicator.GetRange(0f); } else if (pModule.moduleType == Module.Type.Weapon) { if (hitModule.parentBase) { rangeIndicator.GetRange(indicatorRange * hitModule.parentBase.GetRange()); } else { rangeIndicator.GetRange(indicatorRange * WeaponModule.indieRange); } } else { rangeIndicator.GetRange(indicatorRange); } } else { RangeIndicator.ForceRequestRange(pModule.gameObject, rangeIndicator.gameObject); } if (isRotting) { ang = Mathf.RoundToInt(Angle.CalculateAngle(placePos, pos) / 90f) * 90; if (Input.GetButton("LCtrl")) { placeRot = Quaternion.Euler(0, 0, ang); } } else { ang = placeRot.eulerAngles.z; } if (Input.GetMouseButtonDown(1)) { CancelPurchase(); } if (!purchaseMenu.isOpen) { if (Input.GetMouseButtonUp(0)) { PlaceModule(); } if (Input.GetMouseButtonDown(0)) { isRotting = true; } } } if (!EnemyManager.waveStarted) { if (!isPlacing && isEditingWalls) { wallGraphicStart = wallDragGraphic.transform.position + wallDragGraphic.transform.localScale / 2f; wallGraphicEnd = wallDragGraphic.transform.position - wallDragGraphic.transform.localScale / 2f; if ((Input.GetMouseButtonDown(1) && wallDragStatus == WallDragStatus.Adding) || (Input.GetMouseButtonDown(0) && wallDragStatus == WallDragStatus.Removing)) { wallDragStatus = WallDragStatus.Inactive; } if (Input.GetMouseButtonDown(0) && wallDragStatus == WallDragStatus.Inactive && !(HoverContext.hoveringButton && HoverContext.hoveringButton.tag == "DarkOverlay")) { wallDragStatus = WallDragStatus.Adding; wallDragStart = pos; wallDragStart = MovePosInsideBattlefield(pos, 0.5f); wallDragGraphic.sharedMaterial.color = Color.green; } if (Input.GetMouseButtonUp(0) && wallDragStatus == WallDragStatus.Adding) { wallDragStatus = WallDragStatus.Inactive; Game.ChangeWalls(new Rect(wallGraphicStart.x, wallGraphicStart.y, wallGraphicEnd.x, wallGraphicEnd.y), Game.WallType.Player); wallDragGraphic.sharedMaterial.color = Color.white; HoverContext.ChangeText(""); Game.PlaySFXAudio(placementAudio); } if (Input.GetMouseButtonDown(1) && wallDragStatus == WallDragStatus.Inactive && !(HoverContext.hoveringButton && HoverContext.hoveringButton.tag == "DarkOverlay")) { wallDragStatus = WallDragStatus.Removing; wallDragStart = MovePosInsideBattlefield(pos, 0.5f); wallDragGraphic.sharedMaterial.color = Color.red; } if (Input.GetMouseButtonUp(1) && wallDragStatus == WallDragStatus.Removing) { wallDragStatus = WallDragStatus.Inactive; Game.ChangeWalls(new Rect(wallGraphicStart.x, wallGraphicStart.y, wallGraphicEnd.x, wallGraphicEnd.y), Game.WallType.None); wallDragGraphic.sharedMaterial.color = Color.white; HoverContext.ChangeText(""); Game.PlaySFXAudio(placementAudio); } if (wallDragStatus != WallDragStatus.Inactive) { Vector3 locPos = MovePosInsideBattlefield(pos, 0.5f); wallDragGraphic.transform.localScale = new Vector3(Mathf.Abs(locPos.x - wallDragStart.x), Mathf.Abs(locPos.y - wallDragStart.y)) + Vector3.one; wallDragGraphic.transform.position = new Vector3(wallDragStart.x + (locPos.x - wallDragStart.x) / 2f, wallDragStart.y + (locPos.y - wallDragStart.y) / 2f); wallDragGraphic.sharedMaterial.mainTextureScale = new Vector2(wallDragGraphic.transform.localScale.x, wallDragGraphic.transform.localScale.y); //Vector3 absStart = new Vector3(Mathf.Abs(wallDragStart.x), Mathf.Abs(wallDragStart.y)); //Vector3 absPos = new Vector3(Mathf.Abs(pos.x), Mathf.Abs(pos.y)); Rect rect = Game.PositivizeRect(new Rect(wallGraphicStart.x, wallGraphicStart.y, wallGraphicEnd.x, wallGraphicEnd.y)); int rectX = Mathf.RoundToInt(rect.x); int rectY = Mathf.RoundToInt(rect.y); int rectW = Mathf.RoundToInt(rect.width); int rectH = Mathf.RoundToInt(rect.height); if (wallDragStatus == WallDragStatus.Adding) { HoverContext.ChangeText("Cost: " + Game.GetWallingCost(rectX, rectY, rectW, rectH, Game.WallType.Player)); } else { HoverContext.ChangeText("Cost: " + Game.GetWallingCost(rectX, rectY, rectW, rectH, Game.WallType.None)); } } else { wallDragGraphic.transform.position = MovePosInsideBattlefield(pos, 0.5f) + Vector3.forward; wallDragGraphic.transform.localScale = Vector3.one; wallDragGraphic.sharedMaterial.mainTextureScale = new Vector2(wallDragGraphic.transform.localScale.x, wallDragGraphic.transform.localScale.y); HoverContext.ChangeText(""); } } } if (!isPlacing && !isEditingWalls && Game.currentScene != Scene.BattlefieldEditor) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, -camDepth * 2f, turretLayer)) { Module mod = hit.collider.GetComponent <Module> (); if (HoverContext.cur.IsReachable(mod.transform)) { hoverMarker.transform.position = hit.collider.transform.position + Vector3.forward * (camDepth + 1); hoverMarker.transform.localScale = Vector3.one * mod.moduleClass; } if (isUpgrading) { upgradingMarker.transform.position = hit.collider.transform.position + Vector3.right * mod.moduleClass * 2f; if (mod.GetUpgradeCost((int)mod.moduleType) > Game.credits || !mod.IsAssemblyUpgradeable(-1)) { upgradingMarker.color = Color.red; } else { upgradingMarker.color = Color.green; } } } else if (contextMenu && !contextMenu.gameObject.activeSelf) { hoverMarker.transform.position = Vector3.right * 10000f; upgradingMarker.transform.position = (Vector3)(Vector2)(Camera.main.ScreenToWorldPoint(Input.mousePosition) + Vector3.right * 2f) + Vector3.forward * (camDepth + 1f); upgradingMarker.color = Color.white; } } if (isUpgrading) { if (Input.GetMouseButtonDown(1)) { CancelAll(); } } }
public void instantiateRangeIndicator(GameObject player) { rangeIndicator = new RangeIndicator(); rangeIndicator.Initialize(player); indicatorActive = false; }
//Fonction appellee lorsque le joueur confirme public void ConfirmChoice() { if (TowerPlacement.Instance != null) { TowerPlacement.Instance.DeleteInstance(); return; } else { DisplayCancelText(); } GameObject tower = Instantiate(towerPrefab); //On cree une nouvelle tour TowerPlacement towerPlacement = tower.GetComponent <TowerPlacement>(); //On recupere l'objet gerant le placement d'une tour SpriteRenderer[] renderers = tower.GetComponentsInChildren <SpriteRenderer>(); //On recupere les differents affichages towerPlacement.towerFabric = this; // On rappel la fabrique a la nouvelle instance foreach (SpriteRenderer renderer in renderers) { switch (renderer.name) { case "Base": //On met l'affichage de la base a jour renderer.sprite = baseImage.sprite; towerPlacement.baseSprite = baseImage.sprite; break; case "Weapon": //On met l'affichage de l'arme a jour renderer.sprite = weaponImage.sprite; towerPlacement.weaponSprite = weaponImage.sprite; break; } } towerPlacement.baseType = currentBasePick; //On communique a l'objet le type de base choisi towerPlacement.weaponType = currentWeaponPick; //On communique a l'objet le type d'arme choisi towerPlacement.SetCost(cost); //On definit le cout de la tour a placer //On ajoute un affichage de la portee de la tour RangeIndicator rangeIndicator = Instantiate(towerRangeIndicator, towerPlacement.transform).GetComponent <RangeIndicator>(); float range; switch (currentWeaponPick) //On recupere la portee en fonction du type d'arme { case WeaponType.Balliste: range = GameBalance.Ballista.range; break; case WeaponType.Mortier: range = GameBalance.Mortar.range; break; default: Debug.LogError("Arme inexistante !"); return; } rangeIndicator.SetRange(range); //On met a jour la portee a afficher rangeIndicator.SetSelected(true); //On active l'affichage de la portee PlaySoundOnEvent.Instance.PlayTowerForged(); //On joue le son de forge de tour }
public static WalkerIndicator getIndicatorByString(string input) { string[] args; if (input.Contains("_") == false) { args = new string[] { input } } ; else { args = input.Split('_'); } WalkerIndicator selected = null; if (args[0] == BolingerBandsIndicator.Name) { selected = new BolingerBandsIndicator(long.Parse(args[1]), double.Parse(args[2])); } if (args[0] == MACDContinousIndicator.Name) { selected = new MACDContinousIndicator(long.Parse(args[1]), long.Parse(args[2]), long.Parse(args[3])); } if (args[0] == MACDIndicator.Name) { selected = new MACDIndicator(long.Parse(args[1]), long.Parse(args[2]), long.Parse(args[3])); } if (args[0] == MovingAverageIndicator.Name) { selected = new MovingAverageIndicator(long.Parse(args[1])); } if (args[0] == MovingAveragePriceSubtractionIndicator.Name) { selected = new MovingAveragePriceSubtractionIndicator(long.Parse(args[1])); } if (args[0] == MovingAverageSubtractionIndicator.Name) { selected = new MovingAverageSubtractionIndicator(long.Parse(args[1]), long.Parse(args[2])); } if (args[0] == MovingAverageSubtractionCrossoverIndicator.Name) { selected = new MovingAverageSubtractionCrossoverIndicator(long.Parse(args[1]), long.Parse(args[2])); } if (args[0] == RangeIndicator.Name) { selected = new RangeIndicator(long.Parse(args[1])); } if (args[0] == RSIBorderCrossoverIndicator.Name) { selected = new RSIBorderCrossoverIndicator(long.Parse(args[1]), double.Parse(args[2])); } if (args[0] == RSIBorderIndicator.Name) { selected = new RSIBorderIndicator(long.Parse(args[1]), double.Parse(args[2])); } if (args[0] == RSIIndicator.Name) { selected = new RSIIndicator(long.Parse(args[1])); } if (args[0] == RSIMACrossoverContinousIndicator.Name) { selected = new RSIMACrossoverContinousIndicator(long.Parse(args[1]), long.Parse(args[2])); } if (args[0] == RSIMACrossoverIndicator.Name) { selected = new RSIMACrossoverIndicator(long.Parse(args[1]), long.Parse(args[2])); } if (args[0] == StandartDeviationIndicator.Name) { selected = new StandartDeviationIndicator(long.Parse(args[1])); } if (args[0] == StochBorderCrossoverIndicator.Name) { selected = new StochBorderCrossoverIndicator(long.Parse(args[1]), double.Parse(args[2])); } if (args[0] == StochBorderIndicator.Name) { selected = new StochBorderIndicator(long.Parse(args[1]), double.Parse(args[2])); } if (args[0] == StochIndicator.Name) { selected = new StochIndicator(long.Parse(args[1])); } if (args[0] == TestIndicator.Name) { selected = new TestIndicator(); } if (args[0] == TimeDayOfWeekIndicator.Name) { selected = new TimeDayOfWeekIndicator(); } if (args[0] == TimeOfDayIndicator.Name) { selected = new TimeOfDayIndicator(); } if (args[0] == TimeOpeningHoursIndicator.Name) { selected = new TimeOpeningHoursIndicator(); } if (args[0] == VolumeAtPriceIndicator.Name) { selected = new VolumeAtPriceIndicator(long.Parse(args[1]), double.Parse(args[2]), long.Parse(args[3])); } if (selected == null) { throw new Exception("Name not found: " + args[0]); } if (selected.getName() != input) { throw new Exception(input + " != " + selected.getName()); } return(selected); }
public static WalkerIndicator getRandomIndicator() { WalkerIndicator theIndicator = null; long timeframeOne = z.Next(1, 2880) * 60 * 1000; long timeframeTwo = z.Next(1, 2880) * 60 * 1000; long timeFrameThree = z.Next(1, 2880) * 60 * 1000; long timeFrameSmaller = z.Next(1, 2880) * 60 * 1000; switch (z.Next(0, 18)) //Todo: set max value for choosing the indicator { case 0: theIndicator = new BolingerBandsIndicator(timeframeOne, getRanDouble(1d, 5d)); break; case 1: theIndicator = new MACDContinousIndicator(timeframeOne, timeframeTwo, timeFrameSmaller); break; case 2: theIndicator = new MACDIndicator(timeframeOne, timeframeTwo, timeFrameSmaller); break; case 3: theIndicator = new MovingAveragePriceSubtractionIndicator(timeframeOne); break; case 4: theIndicator = new MovingAverageSubtractionCrossoverIndicator(timeframeOne, timeframeTwo); break; case 5: theIndicator = new MovingAverageSubtractionIndicator(timeframeOne, timeframeTwo); break; case 6: theIndicator = new RangeIndicator(timeframeOne); break; case 7: theIndicator = new RSIBorderCrossoverIndicator(timeframeOne, getRanDouble(0.1, 0.4)); break; case 8: theIndicator = new RSIBorderIndicator(timeframeOne, getRanDouble(0.1, 0.4)); break; case 9: theIndicator = new RSIIndicator(timeframeOne); break; case 10: theIndicator = new RSIMACrossoverContinousIndicator(timeframeOne, timeFrameSmaller); break; case 11: theIndicator = new RSIMACrossoverIndicator(timeframeOne, timeFrameSmaller); break; case 12: theIndicator = new StandartDeviationIndicator(timeframeOne); break; case 13: theIndicator = new StochBorderCrossoverIndicator(timeframeOne, getRanDouble(0.1, 0.4)); break; case 14: theIndicator = new StochBorderIndicator(timeframeOne, getRanDouble(0.1, 0.4)); break; case 15: theIndicator = new StochIndicator(timeframeOne); break; case 16: theIndicator = new VolumeAtPriceIndicator(timeframeOne, getRanDouble(0.0003, 0.002), z.Next(1000 * 30, 1000 * 60 * 10)); break; //Not sure about stepsize todo case 17: theIndicator = new TimeOfDayIndicator(); //Only once? break; case 18: theIndicator = new TimeDayOfWeekIndicator(); //Todo: Only once? break; default: throw new Exception("Fired a unexpected random value"); } return(theIndicator); }
public void instantiateRangeIndicator(GameObject player) { rangeIndicator = new RangeIndicator (); rangeIndicator.Initialize (player); indicatorActive = false; }