public void SelectObject(GameObject go) { this.displayText.text = go.name; tileMoveable = go.GetComponent <TileMoveable>(); discreteSpeedMoveable = go.GetComponent <DiscreteSpeedMoveable>(); if (tileMoveable != null) { if (tileMoveable.MaxMoveDistance == tileMoveable.CurrentMoveDistance) { UnlockSpeedPanel(); } else { LockSpeedPanel(); } } UpdatePotentialSlider(); UpdateDiscreteSpeedSlider(); turret = go.GetComponent <TurretScript>(); if (turret != null) { } }
public GameObject CreateTurret(Vector3 pos) { GameObject newTurret = null; int price = TurretInfo.GetTurretInfo(selectableTurrets[selectedTurret]).price[0]; if (stageController.gold >= price) { newTurret = Instantiate(selectablePrefabs[selectedTurret]); TurretScript ts = newTurret.GetComponent <TurretScript>(); ts.SetPosition(pos); list_turret.Add(ts); if (ts.turretID == TurretInfo.TURRET_MINORIKO) { MinorikoScript ms = newTurret.GetComponent <MinorikoScript>(); if (ms != null) { list_minoriko.Add(ms); } } stageController.gold -= price; } return(newTurret); }
void Awake() { turretscript = GetComponentInParent<TurretScript> (); muzzlerenderer = GetComponentInChildren<MeshRenderer> (); turretParticleSys = GetComponent<ParticleSystem> (); muzzleLight = GetComponentInChildren<Light> (); }
public void SetSelectedTurret(TurretScript turret) { selectedTurret = turret; UpdateDisplay(selectedTurret.turretToRotateHorizontal.transform.forward); this.Show(); }
void deactivateTurret(int i) { GameObject o = turrets[i]; TurretScript t = o.GetComponent <TurretScript>(); t.setActive(false); }
// Update is called once per frame void Update() { // check stage of the wave if (gameCtrl.wavePhase == GameManagerScript.EWavePhase.ECombat) { if (Input.GetButton("Fire1")) { // checks time of the last shot // if the certain amount of time has passed fire the projectile if (lastShotTime + fireRate < Time.time) { FireGun(); lastShotTime = Time.time; } } } else if (gameCtrl.wavePhase == GameManagerScript.EWavePhase.EPreparation) { if (Input.GetButton("Fire1")) { // if the raycast from mouse is turret RaycastHit hit = ReturnHitPoint(); if (hit.collider.gameObject != null) { if (hit.collider.tag == "Turret") { selectedTurret = hit.collider.gameObject.GetComponentInParent <TurretScript>(); } } } } // rotates turret towards mouse position TurretFaceDirection(); }
public override void ResetState(IInteractable turret) { _turretScript = (TurretScript)turret; _isAiming = false; _isFiring = false; _isReady = false; }
public void TurretInteraction(TurretScript turret) { if (GetGunInHolster() == null) { HolsterGun(); _playerController.SwitchState <TurretState>(turret); } }
public static TurretScript Create(Transform parent, Consts.MoveDirection _direction) { GameObject pre = Resources.Load("Prefabs/Game/EnemyDrone", typeof(GameObject)) as GameObject; GameObject bullet = GameObject.Instantiate(pre, parent); TurretScript script = bullet.GetComponent <TurretScript>(); script.direction = _direction; return(script); }
public static bool Prefix(TurretScript __instance, ref int id, Vector3 targ, int dmg) { if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout) { __instance.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, id, targ, dmg)); return(false); } GadgetNetwork.ConvertIDToLocal(ItemRegistry.Singleton /* ProjectileRegistry */, ref id); return(true); }
public virtual void SetBullet(TurretScript ts) { this.damage = ts.bulletDamage; this.effect = ts.bulletEffect; this.effectTime = ts.bulletEffectTime; this.type = ts.bulletType; this.target = ts.target; this.turret = ts; }
public static void destroyTurret(TurretScript script) { for (int i = 0; i < turretList.Count; i++) { if (turretList[i] == script) { GameObject.Destroy(script.gameObject); turretList.RemoveAt(i); break; } } }
// Start is called before the first frame update void Start() { uiHandler = GameObject.FindWithTag("GameController").GetComponent <UIHandler>(); frontTurret = transform.parent.GetChild(0).GetChild(0).GetChild(0).GetComponent <TurretScript>(); backTurret = transform.parent.GetChild(0).GetChild(0).GetChild(1).GetComponent <TurretScript>(); targetPoint = calculatePoint(); frontTurret.targetPoint = targetPoint; backTurret.targetPoint = targetPoint; }
// Update is called once per frame void Update() { if (GameManagerScript.instance.isPaused) { return; } if (inputState == TouchInputState.UNITSELECT) { TouchPinch(); } if (inputState == TouchInputState.UNITMOVE) { if (Input.GetMouseButtonDown(0)) { if (!EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId)) { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { if (hit.transform.gameObject.isStatic) { for (int i = 0; i < selectedUnitList.Count; i++) { selectedUnitList[i].targetPos = hit.point; selectedUnitList[i].canMove = true; selectedUnitList[i].MoveUnit(); Collider[] hitColliders = Physics.OverlapSphere(hit.point, selectedUnitList[i].range); for (int j = 0; j < hitColliders.Length; j++) { if (hitColliders[j] != null) { TurretScript target = hitColliders[j].GetComponent <TurretScript>(); if (target != null) { selectedUnitList[i].target = target.gameObject; } } } } } } } } } }
public void HideTurretInfo() { //showing = false; selected = null; SetLocalPosition(new Vector3(2000, 2000, 0)); RectTransform rt = GameObject.Find("Range").GetComponent <RectTransform>(); rt.anchoredPosition = new Vector2(-1000, -1000); //updateUI.GetComponent<RectTransform>().anchoredPosition = new Vector2(3000, 3000); }
public override void SetBullet(TurretScript ts) { this.damage = ts.bulletDamage; this.effect = ts.bulletEffect; this.effectTime = ts.bulletEffectTime; this.type = ts.bulletType; this.eDamage = ts.explosionDamage; this.eEffect = ts.explosionEffect; this.eRadius = ts.explosionRadius; this.eEffectTime = ts.explosionEffectTime; this.target = ts.target; this.turret = ts; }
public void SetExplosion(TurretScript ts) { this.damage = ts.explosionDamage; this.aoe = ts.explosionAOE; this.radius = ts.explosionRadius; this.effect = ts.explosionEffect; this.effectTime = ts.explosionEffectTime; this.turret = ts; this.target = ts.target; if (target != null) { transform.position = target.transform.position; } }
private void purchaseTurret(int posX, int posY, GameObject turret) { TurretScript turretScript = turret.GetComponent <TurretScript>(); if (turretScript.getCost() > points) { Debug.Log("TURRET TOO EXPENSIVE"); return; } GameObject spawnedTurret = Instantiate(turretToSpawn, new Vector3(posX, posY, 0), transform.rotation); spawnedTurret.GetComponent <TileScript>().setPosition(posX, posY); turrets.Add(spawnedTurret); points -= turretScript.getCost(); }
// Update is called once per frame void FixedUpdate() { if (findTurret == true) { if (turrets[turretIterator].GetComponent <TurretScript>().getActive() == false) { activateTurret(turretIterator); findTurret = false; } turretIterator++; if (turretIterator >= numberOfTurrets) { turretIterator = 0; } } else { frames++; if (frames >= cooldownFrames) /*&& turrets[turretIterator].GetComponent<TurretScript>().getActiveNum() < maxTurrets)*/ { if (turretIterator >= numberOfTurrets) { turretIterator = 0; } if (turrets[turretIterator].GetComponent <TurretScript>().getActive() == false) { activateTurret(turretIterator); turretIterator++; } else { findTurret = true; } frames = 0; if (cooldownFrames > /*10*/ activationCooldown) { cooldownFrames -= activationCooldown /*10*/; for (int i = 0; i < numberOfTurrets; i++) { GameObject o = turrets[i]; TurretScript t = o.GetComponent <TurretScript>(); t.SetLazerCooldown(t.GetLazerCooldown() - /*0.1f*/ decreaseLazerCooldown); t.SetLazerSpeed(t.GetLazerSpeed() + /*.1f*/ increaseLazerSpeed); } } } } }
public void Spawn(int randTurret) { RandTurret = randTurret; isSpawning = true; if (isSpawning == true) { // Debug.Log ("Should have spawned"); isSpawning = false; // RandTurret = Random.Range (0, 1); Vector3 position = Vector3.zero; if (directionFrom == 90) { TurretWidth = (Turret[RandTurret].GetComponent <SpriteRenderer> ().sprite.bounds.max.x) * 2; position.Set(Random.Range(RoomMinX + TurretWidth, RoomMaxX - TurretWidth), transform.position.y, 0.0f); // return; } else if (directionFrom == 270) { TurretWidth = (Turret[RandTurret].GetComponent <SpriteRenderer> ().sprite.bounds.max.x) * 2; position.Set(Random.Range(RoomMinX + TurretWidth, RoomMaxX - TurretWidth), transform.position.y, 0.0f); // return; } else if (directionFrom == 180) { TurretHeight = (Turret[RandTurret].GetComponent <SpriteRenderer> ().sprite.bounds.max.y) * 2; position.Set(transform.position.x, Random.Range(RoomMinY + TurretHeight, RoomMaxY - TurretHeight), 0.0f); // return; } else if (directionFrom == 0) { TurretHeight = (Turret[RandTurret].GetComponent <SpriteRenderer> ().sprite.bounds.max.y) * 2; position.Set(transform.position.x, Random.Range(RoomMinY + TurretHeight, RoomMaxY - TurretHeight), 0.0f); } Quaternion rotation = Quaternion.identity; GameObject turretGameObject = (GameObject)Instantiate(Turret[RandTurret], position, rotation); TurretScript tScript = turretGameObject.GetComponent <TurretScript> (); //Debug.Log ("tScript"); tScript.setTurretType(RandTurret); tScript.setAnim(true, directionFrom); } }
public void SaleTurret(TurretScript ts) { stageController.gold += ts.GetSaleGold(); GameObject.Find("TurretUpdateUI").GetComponent <TurretUpdateUIController>().HideTurretInfo(); Vector3Int aPos = mapController.WorldToArray(ts.GetPosition()); mapController.mapArray[aPos.x, aPos.y] = Utils.GROUND; DeleteTurret(ts); AudioManager.instance.PlaySound("se_sell"); //敌人改变默认路径 GameObject.Find("Map").GetComponent <PathFinder>().RefreshDefaultPath(); }
public void UpdateTurret(TurretScript ts) { Debug.Log("升级防御塔!"); if (ts.level == ts.maxLevel) { return; } if (stageController.gold >= ts.GetUpdateGold()) { stageController.gold -= ts.GetUpdateGold(); ts.LevelUp(); AudioManager.instance.PlaySound("se_levelup"); } }
private void upgradeTurret(GameObject turret) { TurretScript turretScript = turret.GetComponent <TurretScript>(); if (turretScript.getUpgradeCost() > points) { Debug.Log("UPGRADE TOO EXPENSIVE"); return; } turretScript.addDamage(1); turretScript.addFireRatio(10); turretScript.addPierce(1); turretScript.addRange(1); turretScript.addProjectyleSpeed(1); points -= turretScript.getUpgradeCost(); Debug.Log("Turret Upgraded!"); }
public void DeleteTurret(TurretScript ts) { if (ts.turretID == TurretInfo.TURRET_MINORIKO) { MinorikoScript ms = ts.gameObject.GetComponent <MinorikoScript>(); if (ms != null && list_minoriko.Contains(ms)) { list_minoriko.Remove(ms); } } if (list_turret.Contains(ts)) { Destroy(ts.gameObject); list_turret.Remove(ts); } }
void Start() { // Disables cursor Cursor.visible = false; // Assigns the camera variable to the main camera cameraTransform = Camera.main.transform; // Assigns the stright speed to the player's speed float straightPlayerSpeed = playerSpeed; // Start-up for turret pick-up functionality carryingTurret = false; // Gets reference to turret turret = GameObject.FindGameObjectWithTag("Turret"); TS = turret.GetComponent <TurretScript>(); }
// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { RaycastHit hit; Ray ray = cameraView.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { GameObject objectHit = hit.collider.gameObject; if (objectHit.tag.Equals(turretTag)) { upgradePanel.SetActive(true); turret = objectHit.GetComponent <TurretScript>(); updateText(); } } } }
//public bool showing = false; void Awake() { updateUI = GameObject.Find("TurretUpdateUI"); controller = GameObject.Find("TurretSelectUI").GetComponent <TurretController>(); GameObject s = GameObject.Find("Sale"); sale = s.GetComponent <Button>(); saleText = s.GetComponentInChildren <Text>(); sale.onClick.AddListener(delegate { if (selected != null) { controller.SaleTurret(selected); selected = null; } }); GameObject u = GameObject.Find("Update"); update = u.GetComponent <Button>(); updateText = u.GetComponentInChildren <Text>(); update.onClick.AddListener(delegate { //Debug.Log("will update a turret"); if (selected != null) { controller.UpdateTurret(selected); ShowTurretInfo(selected); //selected = null; } }); levelText = GameObject.Find("Level").GetComponentInChildren <Text>(); HideTurretInfo(); selected = null; //fireRange = GameObject.Find("FireRange"); }
public void SetLaser(TurretScript ts) { turret = ts; target = ts.target; length = ts.range * 2; origin = turret.transform.position; end = (target.transform.position - turret.transform.position).normalized * this.length + origin; //end = target.transform.position; line.SetPosition(0, origin); line.SetPosition(1, end); line.startWidth = width; line.endWidth = width; this.damage = ts.bulletDamage; //line.enabled = true; }
public GameObject ShowTurretLevel(TurretScript ts) { GameObject go = GetActiveObject(); Text text = go.GetComponent <Text>(); if (ts.level == ts.maxLevel) { text.text = "★"; } else { text.text = ts.level + ""; } text.color = new Color(1, 215f / 255f, 0, 1); text.fontSize = 10; Utils.SetUIPosition(go.GetComponent <RectTransform>(), ts.transform.position); return(go); }
public void SetExplosion(BulletExplosion be) { TurretScript ts = be.turret; this.damage = be.eDamage; this.aoe = ts.explosionAOE; this.radius = be.eRadius; this.effect = be.eEffect; this.effectTime = be.eEffectTime; this.turret = ts; this.target = be.target; if (target != null) { transform.position = target.transform.position; } else { transform.position = be.transform.position; } }
public void ShowTurretInfo(TurretScript ts) { //showing = true; selected = ts; SetLocalPosition(ts.GetPosition()); //updateUI.GetComponent<RectTransform>().anchoredPosition = ts.GetPosition (); if (ts.level >= ts.maxLevel) { update.interactable = false; updateText.text = "--"; } else { update.interactable = true; //Debug.Log("enemy's price is " + ts.price); updateText.text = "$" + ts.GetUpdateGold(); } sale.interactable = true; saleText.text = "$" + ts.GetSaleGold(); levelText.text = (ts.level >= ts.maxLevel) ? "Max" : ts.level + ""; //GameObject.Find("DrawToolkit").GetComponent<DrawToolkit>().DrawCircle(ts.transform .position , ts.range ); RectTransform rt = GameObject.Find("Range").GetComponent <RectTransform>(); rt.anchoredPosition = GetUIPosition(ts.transform.position); float range = Utils.LengthLocalToUI(ts.range * 2 * GameObject.Find("Map").GetComponent <MapController>().cellLocalSize); rt.sizeDelta = new Vector2(range, range); }