Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

41 lines
912B

  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace coa4u
  5. {
  6. class ActionSwitchState : ActionInstant
  7. {
  8. string stateName;
  9. int stateIndex;
  10. public ActionSwitchState(int targetIndex)
  11. : base()
  12. {
  13. stateIndex = targetIndex;
  14. }
  15. public ActionSwitchState(string targetName)
  16. : base()
  17. {
  18. stateName = targetName;
  19. }
  20. public override void Start()
  21. {
  22. base.Start();
  23. if (!(target is SeqActor))
  24. {
  25. throw new Exception("Target is not capable of switching states.");
  26. }
  27. if (stateIndex != null)
  28. {
  29. ((SeqActor)target).SetState(stateIndex);
  30. }
  31. else
  32. {
  33. ((SeqActor)target).SetState(stateName);
  34. }
  35. }
  36. }
  37. }