Exemplo n.º 1
0
 void Awake()
 {
     gold_t         = gold_text.GetComponent <Text>();
     character_anim = Character.GetComponent <Animator>();
     Ad             = transform.GetComponent <AttackDecision>();
     Die_black_img  = Die_black_gb.GetComponent <Image>();
     ingame_sc      = GetComponent <Ingame>();
     fiqure_sc      = GetComponent <Figure>();
 }
        private void BuildPatrolState(State inTargetState, NpcController inNpcController, NpcDataHolder inNpcData, State inIdleState, State inAttackState, State inDieState)
        {
            // --------------------------------------------------------------------------------
            // 1-  Setup Actions
            // --------------------------------------------------------------------------------
            var patrolAction = new PatrolAction(inNpcController, inNpcData.patrolRange, inNpcData.patrolDuration);
            // --------------------------------------------------------------------------------
            // 2-  Setup decisions
            // --------------------------------------------------------------------------------
            var attackDecision = new AttackDecision(inNpcController);
            var idleDecision   = new IdleDecision(patrolAction);
            var dieDecision    = new DieDecision(inNpcController.gameView as IDestructible);
            // --------------------------------------------------------------------------------
            // 3-  Setup Transitions
            // --------------------------------------------------------------------------------
            var transitionToAttack = new Transition()
            {
                hasFalseState = false,
                decision      = attackDecision,
                trueState     = inAttackState
            };

            var transitionToIdle = new Transition()
            {
                hasFalseState = false,
                decision      = idleDecision,
                trueState     = inIdleState
            };
            var transitionToDie = new Transition()
            {
                hasFalseState = false,
                decision      = dieDecision,
                trueState     = inDieState
            };

            // --------------------------------------------------------------------------------
            // 4-  Define State
            // --------------------------------------------------------------------------------
            inTargetState.Define(
                Color.cyan, new Action[] { patrolAction },
                new [] { transitionToDie, transitionToAttack, transitionToIdle }
                );
        }
Exemplo n.º 3
0
    public void Init()
    {
        player     = new GameObject("Player", typeof(BoxCollider2D));
        monster    = new GameObject("Monster", typeof(BoxCollider2D));
        player.tag = "Player";
        handler    = monster.AddComponent <StateController>();

        testChase  = Resources.Load <ChaseDecision>("Decisions/TestChaseDecision");
        testAttack = Resources.Load <AttackDecision>("Decisions/TestAttackDecision");

        chaseState  = Resources.Load <State>("States/ChaseTest");
        attackState = Resources.Load <State>("States/AttackTest");
        idleState   = Resources.Load <State>("States/IdleTest");

        Assert.IsNotNull(player);
        Assert.IsNotNull(monster);
        Assert.IsNotNull(handler);
        Assert.IsNotNull(testChase);
        Assert.IsNotNull(testAttack);
        Assert.IsNotNull(chaseState);
        Assert.IsNotNull(attackState);
        Assert.IsNotNull(idleState);
    }
Exemplo n.º 4
0
 void Awake()
 {
     Gesture_Result    = Result.none;
     AttackDecision_sc = GetComponent <AttackDecision>();
 }