Advertisement
GoodNoodle

Boss

May 19th, 2023
1,162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.31 KB | Source Code | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Linq;
  5. using Unity.VisualScripting;
  6. using UnityEngine;
  7.  
  8. public class Boss : TrainerController, Interactable
  9. {
  10.     float timeTillReaniated;
  11.  
  12.     public SpriteRenderer reanimate;
  13.  
  14.     public bool isalive, isreanimating;
  15.  
  16.     [SerializeField]
  17.     int timeMin = 30, timeMax = 60;
  18.  
  19.     [SerializeField]
  20.     Behaviour movementScript;
  21.  
  22.     public int amounttoUse;
  23.     public override void BattleLost()
  24.     {
  25.         base.BattleLost();
  26.  
  27.         timeTillReaniated = Random.Range(timeMin, timeMax);
  28.         StartCoroutine(Reanimation());
  29.  
  30.     }
  31.  
  32.    
  33.     public IEnumerator Reanimation()
  34.     {
  35.         gameObject.GetComponent<SpriteRenderer>().sprite = reanimate.GetComponent<SpriteRenderer>().sprite;
  36.         isreanimating = true;
  37.         isalive = false;
  38.         movementScript.enabled = false;
  39.         yield return new WaitForSeconds(timeTillReaniated);
  40.  
  41.         movementScript.enabled = true;
  42.         isalive = true;
  43.         isreanimating = false;
  44.         battleLost = false;
  45.         fov.gameObject.SetActive(true);
  46.         StartCoroutine(Heal());
  47.  
  48.     }
  49.  
  50.     public IEnumerator Heal()
  51.     {
  52.  
  53.         yield return new WaitForSeconds(.1f);
  54.  
  55.         var party = GetComponent<Party>();
  56.         party.Creatures.ForEach(p => p.Heal());
  57.         party.PartyUpdated();
  58.  
  59.     }
  60.  
  61.  
  62.     public IEnumerator Smash(Transform initer)
  63.     {
  64.         if (isreanimating)
  65.         {
  66.             yield return DialogueManager.Instance.ShowDialogText("This tree looks like it can be cut.");
  67.  
  68.             var creatureWithCut = initer.GetComponent<Party>().Creatures.FirstOrDefault(p => p.Moves.Any(m => m.Base.Name == "Cut"));
  69.  
  70.             if (creatureWithCut != null)
  71.             {
  72.                 int selectedChoice = 0;
  73.  
  74.                 yield return DialogueManager.Instance.ShowDialogText($"Should {creatureWithCut.Base.name} cut the tree?",
  75.                     choices: new List<string>() { "Yes", "No" },
  76.                     onchoiceSelected: (selection) => selectedChoice = selection);
  77.  
  78.                 if (selectedChoice == 0)
  79.                 {
  80.                     //Yes
  81.                     gameObject.SetActive(false);
  82.                     amounttoUse++;
  83.                 }
  84.             }
  85.         }
  86.     }
  87. }
  88.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement