Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.12 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class LeverItem : MonoBehaviour
  6. {
  7.     public GameObject Charcter_1;
  8.     public GameObject Horse_1;
  9.     public GameObject Cab_1;
  10.     public GameObject Wagon_1;
  11.     private State currentState; //текущее состояние (стреляет, перезаряжается или ничего не делает?)
  12.  
  13.     private void Start()
  14.     {
  15.         SetState(State.Charcter);
  16.     }
  17.     private void SetState(State state)
  18.     {
  19.         currentState = state;
  20.         Charcter_1.SetActive(state == State.Charcter);
  21.         Horse_1.SetActive(state == State.Horse);
  22.         Cab_1.SetActive(state == State.Cab);
  23.         Wagon_1.SetActive(state == State.Wagon);
  24.     }
  25.     private enum State
  26.     {
  27.         Charcter,
  28.         Horse,
  29.         Cab,
  30.         Wagon
  31.     }
  32.     void CharcterOn ()
  33.     {
  34.         SetState(State.Charcter);
  35.     }
  36.     void HorseOn()
  37.     {
  38.         SetState(State.Horse);
  39.     }
  40.     void CabOn()
  41.     {
  42.         SetState(State.Cab);
  43.     }
  44.     void WagonOn()
  45.     {
  46.         SetState(State.Wagon);
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement