예제 #1
0
	public void TransitionToScene (SceneName scenename)
	{
		m_NextLevel = scenename;
		if (transitionState == TransitionEvent.None) {
			transitionState = TransitionEvent.onCloseTransition;

		}
		CloseScene ();
		
		// LoadScene() in animation
		//OpenScene() in update
		
	}
예제 #2
0
    private static TransitionEvent[] RecreateStoryEvents(
        EdgeData data,
        IEventLibrary library)
    {
        TransitionEvent[] events =
            new TransitionEvent[data.EventNames.Length];

        for (int i = 0; i < events.Length; i++)
        {
            EventDescriptor evtDesc =
                library.GetDescriptor(data.EventNames[i]);
            DebugUtil.Assert(evtDesc != null);
            events[i] =
                new TransitionEvent(evtDesc, data.EventParticipants[i]);
        }

        return events;
    }
예제 #3
0
	//-------Close scene-----
	private void CloseScene ()
	{
		if (transitionState == TransitionEvent.onCloseTransition) { 
			if (GameObject.Find ("Player") == null){ //menu thi moi chayj
				GameObject CloseScene = Instantiate (Resources.Load ("CloseFade_Menu")) as GameObject;
				CloseScene.transform.parent = GameObject.FindGameObjectWithTag("Canvas").transform;
				CloseScene.transform.localPosition = new Vector3(0,0,0);
				CloseScene.transform.localScale = Vector3.one;
			}else {
				//chay anim khac'
				GameObject CloseScene = Instantiate (Resources.Load ("CloseFade_Player")) as GameObject;
				CloseScene.transform.parent = GameObject.FindGameObjectWithTag("Canvas").transform;
				CloseScene.transform.localPosition = new Vector3(0,0,0);
				CloseScene.transform.localScale = Vector3.one;
			}
			transitionState = TransitionEvent.onLoadScene;					
		}
	}
예제 #4
0
        public Transition CreatedTransition(String streamId, Int32 version)
        {
            var domainEvent = new StreamCreatedEvent()
            {
                Name = "New Stream",
                Number = 678,
                Type = "Created"
            };

            var transitionEvent = new TransitionEvent(
                typeof(StreamCreatedEvent).AssemblyQualifiedName, 
                domainEvent, 
                null);

            return new Transition(
                new TransitionId(streamId, version), 
                DateTime.UtcNow,
                new List<TransitionEvent> { transitionEvent }, 
                null);
        }
        protected override void Awake()
        {
            Renderer VideoIntro = GetComponent<Renderer>();
            movie = (MovieTexture)VideoIntro.material.mainTexture;
            audioIntro = GetComponent<AudioSource>();
            audioIntro.clip = movie.audioClip;

            if (OnTransitionStarted == null)
                OnTransitionStarted = new TransitionEvent();

            OnTransitionStarted.AddListener(t => StartCoroutine(_PlayVideo()));
            OnTransitionEnded.AddListener(t =>
            {
                if (movie.isPlaying)
                {
                    StopAllCoroutines();
                    movie.Stop();
                    audioIntro.Stop();
                }
            });
            base.Awake();
        }
예제 #6
0
        protected override void Awake()
        {
            this.canvasGroup = GetComponent<CanvasGroup>();
            animator = GetComponent<Animator>();
            animator.enabled = false;

            if (!OnTransitionStarted)
                OnTransitionStarted = new TransitionEvent();

            OnTransitionStarted.AddListener(
                t =>
                {
                    animator.enabled = true;
                    animator.SetTrigger(transitionType.ToString());
                    animator.speed = 1 / duration;
                    StartCoroutine(WaitBeforEnding(duration));
                }
                );

            if (presetAlpha)
                this.canvasGroup.alpha = (int)transitionType;

            base.Awake();
        }
예제 #7
0
 private IEnumerable<SmartObject> GetParticipants(TransitionEvent evt)
 {
     return this.GetParameters(evt).Cast<SmartObject>();
 }
예제 #8
0
 public static void Transition(TransitionEvent e)
 {
     Scene.Dispatch <ScreenTransition.TransitionEvent>(e);
 }
예제 #9
0
 private void DeselectAll(TransitionEvent evt)
 {
     foreach (SmartObject obj in this.GetParticipants(evt))
     {
         Highlight highlight = obj.GetComponent<Highlight>();
         if (highlight != null)
             highlight.HighlightOff();
     }
 }
예제 #10
0
 /// <summary>
 /// Converts the id list to actual live object instances for
 /// execution
 /// </summary>
 private IList<IHasState> GetParameters(TransitionEvent evt)
 {
     List<IHasState> result = new List<IHasState>();
     foreach (uint id in evt.Participants)
         result.Add(ObjectManager.Instance.GetObjectById(id));
     return result;
 }
예제 #11
0
 /// <summary>
 /// Perform a transion between states.
 /// </summary>
 /// <param name="transEvent">An event that is occuring when a packet arrives.</param>
 /// <param name="packet">The packet received over the network.</param>
 public void DoTransition(TransitionEvent transEvent, NetworkPacket packet)
 {
     Tuple<NetworkState, TransitionAction> transition = null;
     //try
     {
         transition = TransitionTable[new Tuple<NetworkState, TransitionEvent>(CurrentState, transEvent)];
         transition.Item2(packet);
         CurrentState = transition.Item1;
     }
     //catch (Exception error)
     //{
     //    Debug.WriteLine("You managed to break the NetStateMachine. Congratulations, asshole: {0}", new Object[] {error.Message});
     //    Debug.WriteLine("Violating Transition: {0} - {1}",new Object[] {CurrentState,transEvent});
     //    throw error;
     //}
     return;
 }
예제 #12
0
 /// <summary>
 /// Register a new transition inside the state machine.
 /// </summary>
 /// <param name="previousState">The state being transitioned out of.</param>
 /// <param name="eventPacket">The type of packet received over the network.</param>
 /// <param name="nextState">The state to transition into.</param>
 /// <param name="action">An action to perform before transitioning.</param>
 public void RegisterTransition(NetworkState previousState, TransitionEvent transEvent, NetworkState nextState, TransitionAction action)
 {
     TransitionTable.Add(new Tuple<NetworkState, TransitionEvent>(previousState, transEvent), new Tuple<NetworkState, TransitionAction>(nextState, action));
     return;
 }
예제 #13
0
	//------Open scene----
	public void OpenScene ()
	{

		if (transitionState == TransitionEvent.onOpenTransition) {
			if (GameObject.Find ("Player") != null){ //chay ben scene Player
				CommonVariable.Instance.banner.Hide ();
				GameObject OpenScene = Instantiate (Resources.Load ("OpenFade_Player")) as GameObject;
				OpenScene.transform.parent = GameObject.FindGameObjectWithTag("Canvas").transform;
				OpenScene.transform.localPosition = new Vector3(0,0,0);
				OpenScene.transform.localScale = Vector3.one;
			} else {
				CommonVariable.Instance.banner.Show();
				GameObject OpenScene = Instantiate (Resources.Load ("OpenFade_Menu")) as GameObject;
				OpenScene.transform.parent = GameObject.FindGameObjectWithTag("Canvas").transform;
				OpenScene.transform.localPosition = new Vector3(0,0,0);
				OpenScene.transform.localScale = Vector3.one;
			}			
			transitionState = TransitionEvent.None;
			NotificationManager.Instance.PostNotification (this, "Load");
		}
	}
예제 #14
0
    /// <summary>
    /// Expands all of the transitions and adds the resulting world states
    /// to the list of nodes during exploration
    /// </summary>
    /// <param name="openList">The list of nodes we haven't explored
    /// yet</param>
    /// <param name="seen">The list of nodes we've seen</param>
    /// <param name="curNode">The current node from the open list</param>
    private static void AddExpansionsToLists(
        EventDescriptor[] evtDescs,
        List<ExplorationNode> openList,
        Dictionary<WorldState, ExplorationNode> seen,
        ExplorationNode curNode)
    {
        // Find all of the event signatures
        foreach (EventDescriptor evtDesc in evtDescs)
        {
            IEnumerable<Tuple<WorldState, uint[]>> expansions =
                GetExpansions(curNode.State, evtDesc);

            // Get all of the expansions
            foreach (Tuple<WorldState, uint[]> expansion in expansions)
            {
                WorldState expansionState = expansion.Item1;
                ExplorationNode expansionNode;

                // If we haven't seen the world state
                if (seen.TryGetValue(expansionState, out expansionNode) == false)
                {
                    expansionNode = new ExplorationNode(expansionState);
                    openList.Add(expansionNode);
                    seen.Add(expansionState, expansionNode);
                }

                DebugUtil.Assert(expansionNode != null);

                TransitionEvent transition = new TransitionEvent(evtDesc, expansion.Item2);
                ExplorationEdge edge = new ExplorationEdge(
                    curNode,
                    expansionNode,
                    transition);
                curNode.AddOutgoing(edge);
                expansionNode.AddIncoming(edge);
            }
        }
    }
예제 #15
0
        static void GenerateStateChartWorkflow(DirectoryInfo outputDirectory, XmlNode rootNode, XmlNode packageNode, XmlNamespaceManager xmlnsManager)
        {
            var packageName    = packageNode.SelectSingleNode("@name").Value;
            var packageTagDict = GetPackageTagList(packageNode, xmlnsManager);

            // 状態遷移図取得
            XmlNodeList stNodeList = packageNode.SelectNodes("*/UML:StateMachine[@xmi.id]", xmlnsManager);

            foreach (XmlNode stateNd in stNodeList)
            {
                List <NormalState> StateActionList = new List <NormalState>(); //< 状態遷移図内で、アクションを含む状態の一覧(開始疑似状態は除く)

                NormalState rootState = new NormalState();                     // 状態遷移図のルート状態

                var stateMachineId   = stateNd.SelectSingleNode("@xmi.id", xmlnsManager).Value;
                var stateMachineName = stateNd.SelectSingleNode("@name", xmlnsManager).Value;

                string stateMachineFullName = packageName + "." + stateMachineName;

                string namespaceValue;
                if (packageTagDict.ContainsKey("namespace"))
                {
                    namespaceValue = packageTagDict["namespace"];
                }
                else
                {
                    namespaceValue = packageName;
                }

                string namespaceDirectoryPath = namespaceValue.Replace(".", "/");
                string pathOutputDirectory    = Path.Combine(outputDirectory.FullName, namespaceDirectoryPath);
                Directory.CreateDirectory(pathOutputDirectory);

                string pathOutput = Path.Combine(pathOutputDirectory, $"{stateMachineFullName}.cs");

                //Console.WriteLine("NodeType: " + nd.LocalName);

                var pseudoStates = stateNd.SelectSingleNode("UML:StateMachine.top/UML:CompositeState/UML:CompositeState.subvertex/UML:Pseudostate", xmlnsManager);
                if (pseudoStates != null)
                {
                    if (rootState.PseudoState != null)
                    {
                        throw new ApplicationException("1つの状態内には、開始疑似状態は1つのみ設定できます。");
                    }
                    var attrnd_id   = pseudoStates.SelectSingleNode("@xmi.id");
                    var attrnd_name = pseudoStates.SelectSingleNode("@name");

                    PseudoState pseudoState = new PseudoState()
                    {
                        Id   = attrnd_id.Value,
                        Name = attrnd_name.Value
                    };
                    AllStateList.Add(pseudoState);

                    rootState.PseudoState = pseudoState;

                    //Console.WriteLine($"開始状態 {attrnd_name.Value} ({attrnd_id.Value})");
                }

                var statesList = stateNd.SelectNodes("UML:StateMachine.top/UML:CompositeState/UML:CompositeState.subvertex/UML:CompositeState", xmlnsManager);
                foreach (XmlNode states_nd in statesList)
                {
                    rootState.SubState.Add(
                        ParseState(states_nd, xmlnsManager, 0, StateActionList)
                        );
                }


                // 遷移取得
                XmlNodeList transitonsNodeList = stateNd.SelectNodes("UML:StateMachine.transitions", xmlnsManager);
                foreach (XmlNode transition_nd in transitonsNodeList)
                {
                    foreach (XmlNode transition_item in transition_nd.SelectNodes("UML:Transition", xmlnsManager))
                    {
                        string transitionName = "", actionName = "";
                        var    transition_bname = transition_item.SelectSingleNode("UML:Transition.trigger/UML:Event/@name", xmlnsManager);
                        if (transition_bname != null) // Transition.triggerを持たない遷移もある(開始疑似状態からの遷移など)
                        {
                            //Console.WriteLine($"TransitionName = {transition_bname.Value}");
                            transitionName = transition_bname.Value;
                        }

                        var transition_effect = transition_item.SelectSingleNode("UML:Transition.effect/UML:Action/@name", xmlnsManager);
                        if (transition_effect != null)
                        {
                            //Console.WriteLine($"ActionName = {transition_effect.Value}");
                            actionName = transition_effect.Value;
                        }


                        string srcId, destId;
                        var    transition_source = transition_item.SelectSingleNode("UML:Transition.source/UML:StateVertex/@xmi.idref", xmlnsManager);
                        //Console.WriteLine($"Source = {transition_source.Value}");
                        srcId = transition_source.Value;
                        var transition_target = transition_item.SelectSingleNode("UML:Transition.target/UML:StateVertex/@xmi.idref", xmlnsManager);
                        //Console.WriteLine($"Target = {transition_target.Value}");
                        destId = transition_target.Value;


                        var rs = from u in AllStateList
                                 where u.Id == srcId
                                 select u;
                        var rd = from u in AllStateList
                                 where u.Id == destId
                                 select u;
                        var srcState  = rs.FirstOrDefault() as State;
                        var destState = rd.FirstOrDefault() as State;
                        if (srcState != null && destState != null)
                        {
                            if (srcState is PseudoState)
                            {
                                if (destState is NormalState normalState)
                                {
                                    normalState.InitialAttribute = true;
                                }
                            }
                            else
                            {
                                if (srcState is NormalState normalState_src && destState is NormalState normalState_dest)
                                {
                                    var eventObj = new TransitionEvent
                                    {
                                        Name        = transitionName,
                                        MethodName  = actionName,
                                        Destination = normalState_dest
                                    };
                                    normalState_src.TransitionEvent.Add(eventObj);

                                    AddTransition(transitionName, eventObj);
                                }
                            }
                        }
                    }
                }

                bool isFrameTransitionStateMachine = false;
                var  tags = GetStateMachineTagList(stateMachineId, rootNode, xmlnsManager);
                if (tags.ContainsKey("FrameTransition") && tags["FrameTransition"].ToUpper() == "TRUE")
                {
                    isFrameTransitionStateMachine = true;
                }


                Console.WriteLine(rootState.Dump(0));


                // ステートマシンのワークフローを出力
                using (System.IO.StreamWriter sw = new System.IO.StreamWriter(pathOutput))
                {
                    sw.WriteLine(@"using System;
using System.Threading.Tasks;
using System.Collections.Generic;
using Hyperion.Pf.Workflow;
using Appccelerate.StateMachine;
using Appccelerate.StateMachine.Infrastructure;
using Appccelerate.StateMachine.Machine;
using Appccelerate.StateMachine.Persistence;
using Appccelerate.StateMachine.Reports;
");
                    sw.WriteLine($"namespace {namespaceValue} {{");

                    if (isFrameTransitionStateMachine)
                    {
                        sw.WriteLine($"public partial class {stateMachineName} : FrameStateMachine<States, Events>, IAsyncPassiveStateMachine {{");
                        //sw.WriteLine($"	public {stateMachineName}(Katalib.WPF.Infrastructures.IContent content) : base(content) {{ }}"); // 出力しない
                    }
                    else
                    {
                        sw.WriteLine($"public partial class {stateMachineName} : AppStateMachine<States, Events>, IAsyncPassiveStateMachine {{");
                    }

                    sw.WriteLine($"	public static string Name = \"{stateMachineFullName}\";");
                    sw.WriteLine("public void Setup() {");

                    rootState.ExportHierarchy(sw);
                    Array.ForEach <NormalState>(StateActionList.Where(prop => prop is NormalState).Cast <NormalState>().ToArray(), prop => prop.ExportTransition(sw));
                    Array.ForEach <NormalState>(StateActionList.Where(prop => prop is NormalState).Cast <NormalState>().ToArray(), prop => prop.ExportEvent(sw, isFrameTransitionStateMachine));

                    var startSubState = rootState.StartSubState;
                    sw.WriteLine($"	Initialize(States.{startSubState.TinyName});");

                    sw.WriteLine("}");

                    Array.ForEach <NormalState>(StateActionList.Where(prop => prop is NormalState).Cast <NormalState>().ToArray(), prop => prop.ExportEventHandler(sw, isFrameTransitionStateMachine));

                    sw.WriteLine("}");

                    sw.WriteLine("}"); // end of namespace
                }
            }
        }
예제 #16
0
	//------Load scene----
	public void LoadScene ()
	{
		if (transitionState == TransitionEvent.onLoadScene) {
			//Load scene ra. 
			Application.LoadLevel (m_NextLevel.ToString ());
		
			transitionState = TransitionEvent.onOpenTransition;
		}
	}
예제 #17
0
 protected abstract void OnTransitionEvent <T>(TransitionEvent <T> transitionEvent) where T : IViewModel, new();
예제 #18
0
 public override int GetHashCode()
 {
     return(StateBefore.GetHashCode() ^
            TransitionEvent.GetHashCode() ^
            StateAfter.GetHashCode());
 }
예제 #19
0
 void NewRound(TransitionEvent nr)
 {
     StartCoroutine(Crossfade(nr.round, 3.0f));
 }
예제 #20
0
 public override void Initialize(UGraphView owner, TransitionEvent transition)
 {
     handler = new BlockNodeHandler(this);
     base.Initialize(owner, transition);
 }
예제 #21
0
 public TransitionEvent(TransitionEvent other)
 {
     this.Descriptor = new EventDescriptor(other.Descriptor);
     this.Participants = (uint[])other.Participants.Clone();
 }