void Awake()
    {
        Type t = typeof(NewBehaviourScript2);

        fSM = GetComponent <FSMComponent>();
        fSM.LoadFSM(this);
        //var mi = t.GetMember("test5", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
        FieldInfo fi = t.GetField("test4", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);

        Debug.Log(fi);
        f.SetAction(0, () => Debug.Log(f.ActionIndex + "  First"));
        f.SetAction(0, () => Debug.Log(f.ActionIndex + "  OOOSD"));
        f.SetAction(1, () => Debug.Log(f.ActionIndex + "  Second"));
        f.SetAction(4, () => Debug.Log(f.ActionIndex + "  Third"));
        //tl.OnUpdate += () => Debug.Log("onUpdate timeline" + tl.CurrenTime);
        tl.OnFinished += () => Debug.LogError("onFinished timeline" + tl.CurrenTime);
        d.OnExit      += () => Debug.Log("Delay :" + d.DelayTime);

        tl.AddEvent(1, () => Debug.Log("Event :" + tl.CurrenTime + " / " + 1));

        tl.AddEvent(3, () => Debug.Log("Event :" + tl.CurrenTime + " / " + 3));

        tl.AddEvent(5, () => Debug.Log("Event :" + tl.CurrenTime + " / " + 5));

        var file = new Framework.Library.Configure.IniFile();

        file.Write("Hello", "world", "test");
    }
        public override void Process(Entity entity)
        {
            FSMComponent             fsm             = entity.GetComponent <FSMComponent>();
            InputIntentComponent     inputIntent     = entity.GetComponent <InputIntentComponent>();
            BinaryDirectionComponent binaryDirection = entity.GetComponent <BinaryDirectionComponent>();

            if (inputIntent.Up)
            {
                LinkOnGroundStateComponent onGround = entity.GetComponent <LinkOnGroundStateComponent>();
                SpeedComponent             speed    = entity.GetComponent <SpeedComponent>();
                speed.SpeedY = -onGround.JumpForce;
                fsm.SetState(entity, "onAir");
                return;
            }
            if (inputIntent.Left ^ inputIntent.Right)
            {
                if (inputIntent.Left)
                {
                    binaryDirection.Direction = BinaryDirection.Left;
                }
                if (inputIntent.Right)
                {
                    binaryDirection.Direction = BinaryDirection.Right;
                }

                if (inputIntent.Run)
                {
                    fsm.SetState(entity, "run");
                    return;
                }
                fsm.SetState(entity, "walk");
                return;
            }
            fsm.SetState(entity, "idle");
        }
Example #3
0
    public void Init(bool isMyCharacter, int idx)
    {
        m_isMyCharacter = isMyCharacter;

        m_Model = transform.Find("people_face_01").gameObject;
        m_Model.transform.localPosition = Vector3.zero;
        m_Model.transform.localRotation = Quaternion.identity;

        m_Animator         = GetComponentInChildren <Animator>();
        m_Animator.enabled = false;

        m_animatorController = m_Animator.runtimeAnimatorController;

        m_CostumeComponent = Common.GetOrAddComponent <CostumeComponent>(gameObject);
        m_CostumeComponent.Init();

        m_StackComponent = Common.GetOrAddComponent <StackComponent>(gameObject);
        m_StackComponent.Init(this);

        m_FSMCompnent = Common.GetOrAddComponent <FSMComponent>(gameObject);
        m_FSMCompnent.Init(this);

        m_InputComponent = Common.GetOrAddComponent <InputComponent>(gameObject);
        m_InputComponent.Init(this);

        OnVictory = m_StackComponent.OnVictory;

        if (m_BillBoard == null)
        {
            m_BillBoard = gameObject.GetComponentInChildren <BillBoard>();
        }

        m_BillBoard.gameObject.SetActive(true);
        if (m_isMyCharacter)
        {
            m_MyPlayerColor = Color.green;

            if (PlayerPrefs.HasKey("myName"))
            {
                NickName = PlayerPrefs.GetString("myName");
            }
            else
            {
                NickName = "Runner";
            }

            m_BillBoard.InitProfileSprite(null);
        }
        else
        {
            m_MyPlayerColor = color[idx];


            m_BillBoard.SetName(Common.strName[Random.Range(0, Common.strName.Length)]);
            m_BillBoard.InitProfileSprite(Common.regionName[Random.Range(0, Common.regionName.Length)]);
        }

        m_BillBoard.SetColor(m_MyPlayerColor);
    }
Example #4
0
 public CharacterActor(GameObject prefab, GameObject parent, Entity character)
 {
     m_graphic = new CharacterGraphic();
     m_graphic.Init(prefab, parent);
     //初始化组件
     m_commandComponent = character.GetComponent <CommandComponent>();
     m_playerComponent  = character.GetComponent <PlayerComponent>();
     m_moveComponent    = character.GetComponent <MoveComponent>();
     m_fsmComponent     = character.GetComponent <FSMComponent>();
 }
Example #5
0
 public virtual void OnStateExit(vIFSMBehaviourController fsmBehaviour)
 {
     if (components == null)
     {
         components = new FSMComponent(actions);
     }
     if (useActions && components != null)
     {
         components.DoActions(fsmBehaviour, vFSMComponentExecutionType.OnStateExit);
     }
 }
 private void Event(Entity entity, Type eventType, EventArgs pe)
 {
     if (eventType == typeof(MapCollisionEventType))
     {
         MapCollisionEventType e = (MapCollisionEventType)pe;
         if (e.Type.HasFlag(MapCollisionType.Down))
         {
             FSMComponent fsm = entity.GetComponent <FSMComponent>();
             fsm.SetState(entity, "idle");
         }
     }
 }
Example #7
0
        private void Start()
        {
            //  yield return new WaitForSeconds(2f);

            m_FSMManager = GameBox.GetComponent <FSMComponent>(); //获取状态机管家组件
            m_IFSM       = m_FSMManager.CreateFSM("Demo");        //创建一个状态机
            m_IFSM.AddState <StateOne>();
            m_IFSM.AddState(typeof(StateTwo));
            m_IFSM.AddCondition <ConditionOne>();
            m_IFSM.AddCondition <ConditionTwo>();
            m_IFSM.ChangeState <StateOne>(); //初始状态
        }
Example #8
0
        public virtual void UpdateState(vIFSMBehaviourController fsmBehaviour)
        {
            if (components == null)
            {
                components = new FSMComponent(actions);
            }
            if (useActions && components != null)
            {
                components.DoActions(fsmBehaviour, vFSMComponentExecutionType.OnStateUpdate);
            }

            fsmBehaviour.ChangeState(TransitTo(fsmBehaviour));
        }
Example #9
0
        public virtual void OnStateEnter(vIFSMBehaviourController fsmBehaviour)
        {
            if (resetCurrentDestination)
            {
                fsmBehaviour.aiController.Stop();
            }

            if (components == null)
            {
                components = new FSMComponent(actions);
            }
            if (useActions && components != null)
            {
                components.DoActions(fsmBehaviour, vFSMComponentExecutionType.OnStateEnter);
            }
        }
 private void Event(Entity entity, Type eventType, EventArgs pe)
 {
     if (eventType == typeof(MapCollisionEventType))
     {
         MapCollisionEventType e = (MapCollisionEventType)pe;
         if (!e.Type.HasFlag(MapCollisionType.Down))
         {
             FSMComponent fsm = entity.GetComponent <FSMComponent>();
             fsm.SetState(entity, "onAir");
         }
         else
         {
             SpeedComponent speed = entity.GetComponent <SpeedComponent>();
             speed.SpeedY = 0;
         }
     }
 }
Example #11
0
 public void InitComponent(Transform componentRoot)
 {
     this.ComponentRoot    = componentRoot;
     DataNodeComponent     = FindAndRegisterComponent <DataNodeComponent>();
     DataTableComponent    = FindAndRegisterComponent <DataTableComponent>();
     DownloadComponent     = FindAndRegisterComponent <DownloadComponent>();
     FsmComponent          = FindAndRegisterComponent <FSMComponent>();
     ResourceComponent     = FindAndRegisterComponent <ResourceComponent>();
     SettingComponent      = FindAndRegisterComponent <SettingComponent>();
     SoundComponent        = FindAndRegisterComponent <SoundComponent>();
     TimerComponent        = FindAndRegisterComponent <TimerComponent>();
     WebComponent          = FindAndRegisterComponent <WebComponent>();
     UpdateComponent       = FindAndRegisterComponent <UpdateComponent>();
     LocalizationComponent = FindAndRegisterComponent <LocalizationComponent>();
     VideoComponent        = FindAndRegisterComponent <VideoComponent>();
     InputComponent        = FindAndRegisterComponent <InputComponent>();
     SceneComponent        = FindAndRegisterComponent <SceneComponent>();
 }
Example #12
0
        public void Update()
        {
            FSMComponent[] FSMs = new FSMComponent[] {
                new FSMComponent(new FSMachine(), true),
                new FSMComponent(new FSMachine(), false)
            };

            PositionComponent3D[] positions = new PositionComponent3D[] {
                new PositionComponent3D(new Vector3()),
                new PositionComponent3D(new Vector3(0.0f, 1.0f, 0.0f))
            };

            Vector3 targetPos = null;
            int     targetID  = -1;

            for (int i = 0; i < FSMs.Length; i++)
            {
                if (FSMs[i].m_IsTarget)
                {
                    targetPos = positions[i].m_Position;
                    targetID  = i;
                }
            }

            if (targetPos != null && targetID != -1)
            {
                for (int i = 0; i < FSMs.Length; i++)
                {
                    if (i != targetID)
                    {
                        FSMs[i].UpdateMachine(positions[i].m_Position, targetPos);
                    }
                }
            }
            else
            {
                //WHY IS IT GOING TO GO HERE?
                //Because there is nothing going in the array of FSMs
            }
        }
 public void Setup()
 {
     fsm = new FSMComponent();
 }
Example #14
0
 public void Setup()
 {
     fsm = new FSMComponent();
 }