示例#1
0
    void OnDisplayDialog(LogicArg arg)
    {
        NarrativePlotScriptableObject tem_Plot = (NarrativePlotScriptableObject)arg.GetMessage(M_Event.EVENT_DISPLAY_DIALOG_PLOT);
        MonoBehaviour     other        = (MonoBehaviour)arg.sender;
        AudioSource       otherSpeaker = AddSpeaker(other.gameObject);
        TalkableCharacter sender       = (TalkableCharacter)arg.sender;

        if (tem_Plot != null)
        {
            if (!tem_Plot.important)
            {
                if (tem_Plot.dialogs != null && tem_Plot.dialogs.Count > 0)
                {
                    DisplayUnimportantDialog(tem_Plot.dialogs [0], new DisplayPlot(tem_Plot, otherSpeaker, sender));
                }
            }
            else
            {
                PlotArray.Add(new DisplayPlot(tem_Plot, otherSpeaker, sender));
                if (!IsDisplaying)
                {
                    NextDialog();
                }
            }
        }
    }
示例#2
0
    void OnMoveHeroNetwork(LogicArg arg)
    {
        if (MState == LogicManager.State.WaitStrategy)
        {
            Debug.Log("Get Move MSG");
            MoveHeroMessage msg = (MoveHeroMessage)arg.GetMessage("msg");
            foreach (HeroMoveInfo mInfo in msg.heroMoves)
            {
                foreach (Hero h in heroList)
                {
                    if (h.GetHeroInfo().ID == mInfo.ID)
                    {
                        if (h is NetworkHero)
                        {
                            mInfo.ori         = BattleField.GetReflectBlock(mInfo.ori);
                            mInfo.target      = BattleField.GetReflectBlock(mInfo.target);
                            mInfo.toDirection = BattleField.GetReflectDirection(mInfo.toDirection);
                            ((NetworkHero)h).Move(mInfo);
                        }
                    }
                }
            }

            m_stateMachine.State = State.Battle;
        }
    }
示例#3
0
    void OnDisplay(LogicArg arg)
    {
        TalkableCharacter             character = (TalkableCharacter)arg.sender;
        NarrativePlotScriptableObject plot      = (NarrativePlotScriptableObject)arg.GetMessage(M_Event.EVENT_DISPLAY_DIALOG_PLOT);

        if (plot.important)
        {
            if (character != null && character.NeedMoveCamera())
            {
                character.MoveCamera(m_MainCamera);
                cameraBot.enabled = false;
                Moveable          = false;
                m_isDisplay       = true;
            }
            else
            {
                if (plot != null && plot.lockCamera)
                {
                    Moveable               = false;
                    m_isDisplay            = true;
                    CameraNarrativeSensity = 0.03f;
                }
            }
        }
//		m_UseHeadBob = false;
//		m_Move = false;
//		m_CanJump = false;
    }
示例#4
0
    void OnDisplayNext(LogicArg arg)
    {
        bool important = (bool)arg.GetMessage("important");

        if (important)
        {
            if (lastData != null)
            {
                lastData.lastTime = Time.time - lastData.time;
                dialogData.Add(lastData);
                lastData = null;
            }
            lastData           = new DialogData();
            lastData.time      = Time.time;
            lastData.word      = (string)arg.GetMessage("word");
            lastData.character = (string)arg.GetMessage("character");
        }
    }
示例#5
0
    void OnDefaultBGM(LogicArg arg)
    {
        float fadeTime = -1f;

        if (arg.ContainMessage(M_Event.EVENT_BGM_FADE_TIME))
        {
            fadeTime = (float)arg.GetMessage(M_Event.EVENT_BGM_FADE_TIME);
        }
        SwitchBGM(defaultBGM, false, fadeTime);
    }
示例#6
0
    void OnPlayMusic(LogicArg arg)
    {
        string name = (string)arg.GetMessage(M_Event.EVENT_PLAY_MUSIC_NAME);

        foreach (AudioClip music in playableMusicList)
        {
            if (music.name == name)
            {
                SwitchBGM(music, false);
            }
        }
    }
示例#7
0
 /// Network
 void OnPlaceHeroNetwork(LogicArg arg)
 {
     if (MState == State.WaitPlaceHero)
     {
         PlaceHeroMessage msg = (PlaceHeroMessage)arg.GetMessage("msg");
         foreach (RawHeroInfo hInfo in msg.heroInfo)
         {
             hInfo.block     = BattleField.GetReflectBlock(hInfo.block);
             hInfo.direction = BattleField.GetReflectDirection(hInfo.direction);
             HeroFactory.SetUpEnemyHero(hInfo);
         }
         m_stateMachine.State = State.Strategy;
     }
 }
示例#8
0
    protected override void OnEndDisplayDialog(LogicArg arg)
    {
        base.OnEndDisplayDialog(arg);
        TalkableCharacter character = (TalkableCharacter)arg.GetMessage(M_Event.EVENT_END_DISPLAY_SENDER);

        if (character == this)
        {
            if (m_stateMachine.State == GirlState.Init)
            {
                m_stateMachine.State = GirlState.Walk;
            }

            m_realTalking = false;
        }
    }
示例#9
0
    void OnDisplayThought(LogicArg arg)
    {
        Thought thought = (Thought)arg.GetMessage(M_Event.EVENT_THOUGHT);

        if (thought.thought != null && thought.thought.Length > 1)
        {
            thoughtText.text = thought.thought;
            thoughtBackground.transform.DOKill();
            thoughtBackground.transform.localScale = Vector3.one * 0.001f;
            thoughtSequence = DOTween.Sequence();
            thoughtSequence.Append(thoughtBackground.transform.DOScale(1f, 0.3f));
            thoughtSequence.AppendCallback(delegate() {
                isThoughtOn = true;
            });
            thoughtSequence.AppendInterval(thoughtShowTime);
            thoughtSequence.Append(thoughtBackground.transform.DOScale(0, 0.3f));
            thoughtSequence.AppendCallback(delegate() {
                isThoughtOn = false;
            });
        }
    }
示例#10
0
    virtual protected void OnEndDisplayDialog(LogicArg arg)
    {
        TalkableCharacter character = (TalkableCharacter)arg.GetMessage(M_Event.EVENT_END_DISPLAY_SENDER);

        if (character == this)
        {
            if (isMainTalking)
            {
                if (MainTalkEndEvent != LogicEvents.None)
                {
                    M_Event.FireLogicEvent(MainTalkEndEvent, new LogicArg(this));
                }
                isMainTalking = false;
                IsMainEnded   = true;
            }

            if (IsTalking && gameObject.activeSelf)
            {
                StartCoroutine(DelayBecomeTalkable(becomeTalkableDelay));
            }
        }
    }
示例#11
0
    void InitStateMachine()
    {
        if (IsStateMachineInited)
        {
            return;
        }
        IsStateMachineInited = true;

        m_stateMachine = new AStateMachine <HeroState, LogicEvents> (HeroState.None);

        m_stateMachine.BlindFromEveryState(LogicEvents.PlaceHeroPhase, HeroState.ReadyToPlace);

        m_stateMachine.AddEnter(HeroState.ReadyToPlace, delegate {
            transform.DOMove(oritinalPos, 1f);
        });

        m_stateMachine.AddEnter(HeroState.MoveWithMouse, delegate {
            m_collider.size = new Vector3(0.1f, 0.1f, 1f);
        });

        m_stateMachine.AddUpdate(HeroState.MoveWithMouse, delegate {
            transform.position = InputManager.FocusWorldPos;
        });

        m_stateMachine.AddExit(HeroState.MoveWithMouse, delegate {
            m_collider.size = new Vector3(2.56f, 2.56f, 1f);
        });

        m_stateMachine.AddEnter(HeroState.Prepare, delegate {
            if (TriggerBlock != null)
            {
                TriggerBlock.RegisterHero(this);

                TemBlock = TriggerBlock.BlockInfo;
                LogicManager.Instance.RegisterHero(this);

                transform.DOMove(TriggerBlock.GetCenterPosition(), 0.2f);

                // Disable Collider
                if (m_collider != null)
                {
                    m_collider.enabled = false;
                }
            }
        });

        m_stateMachine.BlindFromEveryState(LogicEvents.StrategyPhase, HeroState.Strategy);
        m_stateMachine.BlindFromEveryState(LogicEvents.AutoBattle, HeroState.Strategy);


        m_stateMachine.AddEnter(HeroState.Strategy, delegate {
            if (TemBlock == null)
            {
                m_stateMachine.State = HeroState.None;
            }
            else
            {
                targetLine.enabled  = false;
                targetArrow.enabled = false;

                if (LogicManager.IsAutoPlay)
                {
                    m_stateMachine.State = HeroState.StrategyAuto;
                }
                else
                {
                    if (!(m_strategy is CustomStrategy))
                    {
                        DestroyImmediate(m_strategy);
                        m_strategy = gameObject.AddComponent <CustomStrategy>();
                        m_strategy.Init(this);
                    }
                    if (m_strategy is CustomStrategy)
                    {
                        ((CustomStrategy)m_strategy).target   = TemSimpleBlock;
                        ((CustomStrategy)m_strategy).isActive = false;
                    }
                }
            }
        });

        m_stateMachine.AddUpdate(HeroState.Strategy, delegate() {
            if (LogicManager.IsAutoPlay)
            {
                m_stateMachine.State = HeroState.StrategyAuto;
            }
        });

        m_stateMachine.BlindStateEventHandler(HeroState.StrategyChoose, delegate(object obj) {
            LogicArg arg = (LogicArg)obj;
            if (arg.type == LogicEvents.ConfirmHero)
            {
//				Block block = (Block)arg.GetMessage(M_Event.BLOCK);
//				if ( TemBlock != null && !TemBlock.Equals(block))
//				{
                m_stateMachine.State = HeroState.Strategy;
//				}
            }
            else if (arg.type == LogicEvents.SelectBlock)
            {
                Block block = (Block)arg.GetMessage(M_Event.BLOCK);

                if (m_move.IsInMoveRange(block.SimpleBlock))
                {
                    ((CustomStrategy)m_strategy).target = block.SimpleBlock;
                    DrawToTarget(block);
                    m_stateMachine.State = HeroState.StrategyDirection;
                }
            }
        });


        m_stateMachine.BlindStateEventHandler(HeroState.StrategyDirection, delegate(object obj) {
            LogicArg arg = (LogicArg)obj;
            if (arg.type == LogicEvents.FingerUp)
            {
                m_stateMachine.State = HeroState.StrategyConfirm;
            }
        });

        m_stateMachine.BlindStateEventHandler(HeroState.StrategyConfirm, delegate(object obj) {
            LogicArg arg = (LogicArg)obj;
            if (arg.type == LogicEvents.ConfirmHero)
            {
                Block block = (Block)arg.GetMessage(M_Event.BLOCK);
                if (TemBlock.Equals(block))
                {
                    m_stateMachine.State = HeroState.StrategyChoose;
                }
            }
            else if (arg.type == LogicEvents.ConfirmMove)
            {
                if (LogicManager.Instance.mode == LogicManager.Mode.SingleBattle)
                {
                    if (arg.sender != this)
                    {
                        m_stateMachine.State = HeroState.Strategy;
                    }
                }
            }
        });

        m_stateMachine.AddEnter(HeroState.StrategyChoose, delegate {
            TemBlock.linkedBlock.visualType = BattleBlock.BlockVisualType.StrategyFocus;
            BattleField.ShowBlock(m_move.GetMoveRange(), BattleBlock.BlockVisualType.StrategyMoveRange);
            BattleField.ShowBlock(new SimBlock[] { TemBlock.SimpleBlock }, BattleBlock.BlockVisualType.StrategyChosenHero, false);
        });

        m_stateMachine.AddEnter(HeroState.StrategyDirection, delegate() {
            targetArrow.enabled = true;
            Block block         = BattleField.GetBlock(((CustomStrategy)m_strategy).target);
            BattleField.ShowBlock(new SimBlock[] { TemBlock.SimpleBlock }, BattleBlock.BlockVisualType.StrategyChosenHero, false);
            targetArrow.transform.position = block.linkedBlock.GetCenterPosition();
        });

        m_stateMachine.AddUpdate(HeroState.StrategyDirection, delegate {
            // set the target arrow to right angle
            Vector3 focusPos = InputManager.FocusWorldPos;
            Block block      = BattleField.GetBlock(((CustomStrategy)m_strategy).target);
            Vector3 toward   = focusPos - block.linkedBlock.GetCenterPosition();
            float angle      = Mathf.Atan2(toward.y, toward.x) * Mathf.Rad2Deg;
            angle            = Mathf.Round((angle) / 90f) * 90f;

            targetArrow.transform.rotation = Quaternion.Euler(0, 0, angle);

            // set the angle of strategy
            ((CustomStrategy)m_strategy).angle = angle;

            // get the direction of the strategy
            Direction direction = ((CustomStrategy)m_strategy).GetDirection();
            BattleField.ShowBlock(m_attack.GetAttackRange(((CustomStrategy)m_strategy).target, direction, GetHeroInfo().AttackRange), BattleBlock.BlockVisualType.StrategyAttackRange);
        });

        m_stateMachine.AddExit(HeroState.StrategyDirection, delegate {
            ((CustomStrategy)m_strategy).isActive = true;
            LogicArg arg = new LogicArg(this);
//			Debug.Log("Fire Confirm Move ");
            M_Event.FireLogicEvent(LogicEvents.ConfirmMove, arg);
        });

        m_stateMachine.AddEnter(HeroState.StrategyConfirm, delegate {
            BattleField.ResetVisualColor(true);
            TemBlock.linkedBlock.visualType = BattleBlock.BlockVisualType.StrategyConfirm;
        });

        m_stateMachine.AddEnter(HeroState.StrategyAuto, delegate() {
            // set up the strategy
            if (!(m_strategy is AIStrategy))
            {
                DestroyImmediate(m_strategy);
                m_strategy = gameObject.AddComponent <AIStrategy>();
                m_strategy.Init(this);
                m_strategy.OnBeforeBattle();
            }
        });

        m_stateMachine.AddEnter(HeroState.BattleMove, delegate {
            targetLine.enabled  = false;
            targetArrow.enabled = false;
        });
    }
示例#12
0
    void OnSwitchBGM(LogicArg arg)
    {
        AudioClip clip = (AudioClip)arg.GetMessage(M_Event.EVENT_SWITCH_BGM_CLIP);

        SwitchBGM(clip, true);
    }
示例#13
0
    void InitStateMachine()
    {
        m_stateMachine = new AStateMachine <HeroState, LogicEvents>(HeroState.None);


        m_stateMachine.BlindStateEventHandler(HeroState.Strategy, delegate(object obj) {
            LogicArg arg = (LogicArg)obj;
            Block block  = (Block)arg.GetMessage(M_Event.BLOCK);
            Debug.Log("Get event" + arg.type);
            if (arg.type == LogicEvents.ConfirmHero)
            {
                Debug.Log("Get Confirm Hero" + block.SimpleBlock + " " + TemBlock.SimpleBlock);
                if (TemBlock != null && TemBlock.Equals(block))
                {
                    m_stateMachine.State = HeroState.StrategyMove;
                }
                else
                {
                    m_stateMachine.State = HeroState.Strategy;
                }
            }
            else if (arg.type == LogicEvents.SelectBlock)
            {
                m_stateMachine.State = HeroState.Strategy;
            }
        });

        m_stateMachine.BlindStateEventHandler(HeroState.StrategyMove, delegate(object obj) {
            LogicArg arg = (LogicArg)obj;
            Block block  = (Block)arg.GetMessage(M_Event.BLOCK);
            if (arg.type == LogicEvents.ConfirmHero)
            {
                if (TemBlock != null && TemBlock.Equals(block))
                {
                    m_stateMachine.State = HeroState.StrategyAttack;
                }
                else
                {
                    m_stateMachine.State = HeroState.Strategy;
                }
            }
            else if (arg.type == LogicEvents.SelectBlock)
            {
                m_stateMachine.State = HeroState.Strategy;
            }
        });

        m_stateMachine.BlindStateEventHandler(HeroState.StrategyAttack, delegate(object obj) {
            LogicArg arg = (LogicArg)obj;
            Block block  = (Block)arg.GetMessage(M_Event.BLOCK);
            if (arg.type == LogicEvents.ConfirmHero)
            {
                if (TemBlock != null && TemBlock.Equals(block))
                {
                    m_stateMachine.State = HeroState.StrategyMove;
                }
                else
                {
                    m_stateMachine.State = HeroState.Strategy;
                }
            }
            else if (arg.type == LogicEvents.SelectBlock)
            {
                m_stateMachine.State = HeroState.Strategy;
            }
        });

        m_stateMachine.AddEnter(HeroState.Strategy, delegate {
            if (m_collider == null)
            {
                m_collider = GetComponent <BoxCollider>();
            }
            if (m_collider != null)
            {
                m_collider.size = new Vector3(2.56f, 2.56f, 1f);
            }
            if (m_collider != null)
            {
                m_collider.enabled = false;
            }
        });

        m_stateMachine.AddEnter(HeroState.StrategyMove, delegate() {
            BattleField.ShowBlock(m_move.GetMoveRange(), BattleBlock.BlockVisualType.MoveRangeEnermy);
        });

        m_stateMachine.AddEnter(HeroState.StrategyAttack, delegate() {
            BattleField.ShowBlock(m_attack.GetAttackRange(), BattleBlock.BlockVisualType.AttackRangeEnermy);
        });

        m_stateMachine.BlindFromEveryState(LogicEvents.StrategyPhase, HeroState.Strategy);

        m_stateMachine.State = HeroState.Strategy;
    }
示例#14
0
 void OnAutoPlay(LogicArg arg)
 {
     isAutoPlay = (bool)arg.GetMessage("ifAuto");
     M_Event.FireLogicEvent(LogicEvents.AutoBattle, new LogicArg(this));
 }
示例#15
0
    void OnEnterSavePoint(LogicArg arg)
    {
        SavePointData data = (SavePointData)arg.GetMessage(M_Event.EVENT_SAVE_POINT);

        lastSavePoint = data;
    }