Advertisement
gameDevTeacher

States

Mar 20th, 2020
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.16 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class StateManager : MonoBehaviour
  6. {
  7.  
  8.     [HideInInspector]
  9.     public enum States { Default, Bucket, Block };
  10.    
  11.     public States states;
  12.        
  13.  
  14.     // Start is called before the first frame update
  15.     void Start()
  16.     {
  17.         states = States.Default;
  18.     }
  19.  
  20.     // Update is called once per frame
  21.     void Update()
  22.     {
  23.         if (states == States.Default)
  24.         {
  25.             print("Ohello Default");
  26.             Default();
  27.             // Kun for å plukke opp ting
  28.         }
  29.         else if(states == States.Bucket)
  30.         {
  31.             print("Bucket");
  32.             Bucket();
  33.  
  34.         }
  35.         else if(states == States.Block)
  36.         {
  37.             print("Bucket");
  38.             Block();
  39.         }
  40.     }
  41.  
  42.     void Default()
  43.     {
  44.  
  45.     }
  46.  
  47.     void Bucket()
  48.     {
  49.         DefaultCode();
  50.        
  51.         if (Input.GetKeyDown(KeyCode.Q))
  52.         {
  53.             states = States.Default;
  54.             print("Dropping the Bucket");
  55.         }
  56.     }
  57.  
  58.     void Block()
  59.     {
  60.  
  61.     }
  62.  
  63.     void DefaultCode()
  64.     {
  65.  
  66.     }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement