//Update heathbar public void UpdateHealthBar(int colorCode, float percent) { if (healthBar == null) { healthBar = this.FindChildObject("ForeHealth").GetComponent <HealthBarSprite>(); } if (colorCode == 2) { healthBar.ChangeToBlue(); } else { healthBar.ChangeToRed(); } healthBar.UpdateHealthBar(percent); }
protected void Start() { try{ anim = this.gameObject.GetComponent <Animator>(); }catch (Exception e) { Debug.Log("No Animator, e: " + e.ToString()); } try{ rigidBody = this.GetComponent <Rigidbody2D>(); }catch (Exception e) { Debug.Log("No Rigidbody, e: " + e.ToString()); } isMoving = false; try{ groundLayer = LayerMask.GetMask("Ground"); }catch (Exception e) { Debug.Log("No ground e: " + e.ToString()); } if (propIcon == null) { propIcon = this.FindChildObject("PropDisplay").GetComponent <SpriteRenderer>(); } if (effectDisplay == null) { effectDisplay = this.FindChildObject("EffectDisplay").GetComponent <Animator>(); } if (healthBar == null) { healthBar = this.FindChildObject("HealthInfo").GetComponent <HealthBarSprite>(); } targetPosition = this.transform.position; isHeadingRight = true; if (rigidBody != null) { rigidBody.simulated = true; } sentGravityNormalize = false; sentFinishMove = false; rigidBody.drag = 100f; // Debug.Log("Init transform: " + this.transform.position); //StartCoroutine(WaitAndInit(0.1f)); }