public bool Sheer() { bool plantSheerSuccess = false; switch (this.PlantSize) { case PlantSizes.XLarge: plantSheerSuccess = true; this.PlantSize = PlantSizes.Large; this.PlantGrowth = 11; this.RootDepth -= 2; break; case PlantSizes.Large: plantSheerSuccess = true; this.PlantSize = PlantSizes.Medium; this.PlantGrowth = 7; this.RootDepth -= 2; break; case PlantSizes.Medium: plantSheerSuccess = true; this.PlantSize = PlantSizes.Small; this.PlantGrowth = 3; this.RootDepth -= 2; break; } AdjustCollider(); AdjustPlantSize(); return(plantSheerSuccess); }
// HP has a max of 6 // HP + 1 / 2 gives the visual for the plant health public void SetPlantSprite(PlantSizes size, int HP) { int index = (int)size / 4 - 1; int modHP = (HP + 1) / 2; SpriteRenderer spriteRenderer = GetComponentInChildren <SpriteRenderer>(); switch (modHP) { case 3: SetSpriteHP3(spriteRenderer, index); break; case 2: SetSpriteHP2(spriteRenderer, index); break; case 1: SetSpriteHP1(spriteRenderer, index); break; case 0: SetSpriteHP0(spriteRenderer, index); break; default: Debug.LogWarning(string.Format("Something wront in SpriteUpdater -- index: {0} / 3, ModHP: {1} / 3", index, modHP)); break; } }
private void Update() { if (!this.IsDragging && DragController.IsDragging) { this.IsDragging = true; AdjustCollider(); SetPositionOffset(); } else if (this.IsDragging && !DragController.IsDragging) { this.IsDragging = false; AdjustCollider(); SetPositionOffset(); } if (!this.IsDragging && this.ActionQueue.Count > 0) { RunActionQueue(); } // For testing purposes if (Input.GetKeyDown(KeyCode.Q)) //XL { this.PlantSize = PlantSizes.XLarge; this.HP = this.MaxHP; PlantSpriteUpdateHandler.SetPlantSprite(this.PlantSize, this.HP); SetColliderSize(); } if (Input.GetKeyDown(KeyCode.W)) //L { this.PlantSize = PlantSizes.Large; this.HP = this.MaxHP; PlantSpriteUpdateHandler.SetPlantSprite(this.PlantSize, this.HP); SetColliderSize(); } if (Input.GetKeyDown(KeyCode.E)) //M { this.PlantSize = PlantSizes.Medium; this.HP = this.MaxHP; PlantSpriteUpdateHandler.SetPlantSprite(this.PlantSize, this.HP); SetColliderSize(); } if (Input.GetKeyDown(KeyCode.R)) //S { this.PlantSize = PlantSizes.Small; this.HP = this.MaxHP; PlantSpriteUpdateHandler.SetPlantSprite(this.PlantSize, this.HP); SetColliderSize(); } if (Input.GetKeyDown(KeyCode.K)) { this.RemoveHealth(); PlantSpriteUpdateHandler.SetPlantSprite(this.PlantSize, this.HP); } }
private void Start() { this.GameController = FindObjectOfType <GameManagerScript>(); if (this.GameController == null) { throw new Exception("No game controller found in scene"); } this.PlantSize = PlantSizes.Small; this.GameController.AddPlantTolist(this); this.DragController = GetComponent <DragDrop>(); this.HP = this.MaxHP; this.PlantGrowth = 4; this.IsPlanted = false; this.IsDead = false; PlantSpriteUpdateHandler.SetPlantSprite(this.PlantSize, this.HP); SetColliderSize(); }
private void AdjustPlantSize() { if (this.PlantGrowth <= 4) { this.PlantSize = PlantSizes.Small; } else if (this.PlantGrowth > 4 && this.PlantGrowth <= 8) { this.PlantSize = PlantSizes.Medium; } else if (this.PlantGrowth > 8 && this.PlantGrowth <= 12) { this.PlantSize = PlantSizes.Large; } else if (this.PlantGrowth > 12) { this.PlantSize = PlantSizes.XLarge; } PlantSpriteUpdateHandler.SetPlantSprite(this.PlantSize, this.HP); SetColliderSize(); }