public override void Attack() { Stop(); if (MyTarget != null) { StartCoroutine(RecurAction()); MyTarget.GetComponent <TowerParent> ().TakeDamage(MyDamage); } }
private void Update() { float distance = 0; if (MyTarget != null) { distance = Vector2.Distance(transform.position, MyTarget.position); } if (distance <= 0.1f) { if (hit && targetIndex < targets.Count) { PickTarget(MyTarget.GetComponent <Collider2D>()); } else if (MyTarget != null) { base.OnTriggerEnter2D(MyTarget.GetComponent <Collider2D>()); } } }
// Use this for initialization new protected void Start() { base.Start(); // not sure where this came from... but commented it out, after updating to ngui 2.3.6a // setting the local cached bot // Check make sure this is actually a BOT! myTempBot = MyTarget.GetComponent <Bot>(); if (myTempBot != null) { // tell the bot that I am tracking you myTempBot.BotNotificationHUB = this; } //maxHeat = Slider.fullSize.x; //maxHeat = Slider.foreground.localScale.y; maxHeat = Slider.fullSize.y; highTemp.alpha = 0.0f; lowTemp.alpha = 0.0f; curTemp.alpha = 0.0f; Pointer.alpha = 0.0f; highTemp.text = myTempBot.MaxTemperature.ToString(); lowTemp.text = myTempBot.MinTemperature.ToString(); //Disable the label on start. WarningAnimation.Play(false); //ThermometerAnimation.Play(false); temp = false; //Animal.alpha = 0.0f; Animal.enabled = false; }
// Update is called once per frame void LateUpdate() { if (MyTarget == null) { // if I dont have a target, remove me from the scene GameObject.Destroy(this.gameObject); return; } // make sure to follow the target //transform.localPosition = MyTarget.transform.position; // this is what worked... but the main object needs to be // its own root. not good. // object needs to be under the 3D UI Root and under a panel //transform.localPosition = Vector3.zero; //transform.position = MyTarget.transform.position; //transform.position = MyTarget.transform.position; Target myTempTarget = MyTarget.GetComponent <Target>(); if (myTempTarget == null) { Debug.LogError("HealthbarObject: Target host, is not a Target object"); return; } if (myTempTarget.IsDestroyed()) { SetSliderAlpha(0); } //Reset the location if the target has a UIHandler. transform.position = myTempTarget.GetUIHandlePosition(); transform.rotation = myTempTarget.transform.rotation; curHealth = myTempTarget.GetHealthPercentage(); //curHealth = myTempTarget.Health; // if (isAlwaysVisible){ // SetSliderAlpha(1.0f); // } // else if (lastFrameHealth == curHealth || curHealth <= 0 || myTempTarget.IsDestroyed()) { SetSliderAlpha(0.0f); } else { SetSliderAlpha(1.0f); } lastFrameHealth = curHealth; if (curHealth <= 0) { curHealth = 0.0009f; } Slider.foreground.localScale = new Vector3(curHealth * this.maxSliderWidth, Slider.foreground.localScale.y, Slider.foreground.localScale.z); }