Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- *
- * Adventure Creator
- * by Chris Burton, 2013-2020
- *
- * "ActionTemplate.cs"
- *
- * This is a blank action template.
- *
- */
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- #if UNITY_EDITOR
- using UnityEditor;
- #endif
- namespace AC
- {
- [System.Serializable]
- public class ActionChangeEmotionAnimation: Action
- {
- // Declare variables here
- public string[] options = new string[] { "Angry", "Sad", "Loopy", "Romantic", "Neutral"};
- public int index = 0;
- Animator m_Animator;
- GameObject Animator;
- public int constantID;bool isLoopy;
- bool isAngry;
- bool isHappy;
- bool isSad;
- bool isRomantic;
- public ActionChangeEmotionAnimation ()
- {
- this.isDisplayed = true;
- category = ActionCategory.Custom;
- title = "Change Emotion Animation";
- description = "Choose an emotion animation and it'll turn off all the others.";
- }
- override public float Run()
- {
- /*
- * This function is called when the action is performed.
- *
- * The float to return is the time that the game
- * should wait before moving on to the next action.
- * Return 0f to make the action instantenous.
- *
- * For actions that take longer than one frame,
- * you can return "defaultPauseTime" to make the game
- * re-run this function a short time later. You can
- * use the isRunning boolean to check if the action is
- * being run for the first time, eg:
- */
- m_Animator = Animator.GetComponent<Animator>();
- switch (index)
- {
- case 0:
- m_Animator.SetBool("isAngry", true);
- m_Animator.SetBool("isLoopy", false);
- m_Animator.SetBool("isSad", false);
- m_Animator.SetBool("isRomantic", false);
- m_Animator.SetBool("isHappy", false);
- break;
- case 1:
- m_Animator.SetBool("isAngry", false);
- m_Animator.SetBool("isLoopy", false);
- m_Animator.SetBool("isSad", true);
- m_Animator.SetBool("isRomantic", false);
- m_Animator.SetBool("isHappy", false);
- break;
- case 2:
- m_Animator.SetBool("isAngry", false);
- m_Animator.SetBool("isLoopy", true);
- m_Animator.SetBool("isSad", false);
- m_Animator.SetBool("isRomantic", false);
- m_Animator.SetBool("isHappy", false);
- break;
- case 3:
- m_Animator.SetBool("isAngry", false);
- m_Animator.SetBool("isLoopy", false);
- m_Animator.SetBool("isSad", false);
- m_Animator.SetBool("isRomantic", true);
- m_Animator.SetBool("isHappy", false);
- break;
- case 4:
- m_Animator.SetBool("isAngry", false);
- m_Animator.SetBool("isLoopy", false);
- m_Animator.SetBool("isSad", false);
- m_Animator.SetBool("isRomantic", false);
- m_Animator.SetBool("isHappy", true);
- break;
- default:
- Debug.LogError("Unrecognized Option");
- break;
- }
- return 0f;
- }
- public override void Skip ()
- {
- /*
- * This function is called when the Action is skipped, as a
- * result of the player invoking the "EndCutscene" input.
- *
- * It should perform the instructions of the Action instantly -
- * regardless of whether or not the Action itself has been run
- * normally yet. If this method is left blank, then skipping
- * the Action will have no effect. If this method is removed,
- * or if the Run() method call is left below, then skipping the
- * Action will cause it to run itself as normal.
- */
- Run ();
- }
- override public void AssignValues ()
- {
- Animator = AssignFile(constantID, Animator);
- }
- #if UNITY_EDITOR
- public override void ShowGUI ()
- {
- Animator = (GameObject)EditorGUILayout.ObjectField("NPC",Animator, typeof(Object), true);
- index = EditorGUILayout.Popup("Emotion",index, options);
- constantID = FieldToID(Animator, constantID);
- Animator = IDToField(Animator, constantID, true);
- AfterRunningOption ();
- }
- public override string SetLabel ()
- {
- // (Optional) Return a string used to describe the specific action's job.
- return string.Empty;
- }
- #endif
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement