Пример #1
0
    private bool isPreHealthHalfDown; //前フレームに体力が半分を下回ったか

    // Use this for initialization
    void Start()
    {
        //Commandの生成
        m_angryMotionCommand              = gameObject.AddComponent <BTAngryMotionBossCommand>();;
        m_playerObserverCommand           = gameObject.AddComponent <BTPlayerObserverBossCommand>();
        m_inkSpewCommand                  = gameObject.AddComponent <BTInkSpewBossCommand>();
        m_instanceEnemyCommand            = gameObject.AddComponent <BTInstanceEnemyBossCommand>();
        m_waitingCommand                  = gameObject.AddComponent <BTWaitingCommand>();
        m_rotationAttackCommand           = gameObject.AddComponent <BTRotationAttackBossCommand>();
        m_crabScissorsCommand             = gameObject.AddComponent <BTCrabScissorsBossCommand>();
        m_momentMaulCommand               = gameObject.AddComponent <BTMomentMaulBossCommand>();
        m_separateContinuousAttackCommand = gameObject.AddComponent <BTSeparateContinuousAttackBossCommand>();
        m_fireBallPreventingEscapeCommand = gameObject.AddComponent <BTFireBallPreventingEscapeBossCommand>();
        m_waiting2Command                 = gameObject.AddComponent <BTWaitingCommand>();
        m_dyingMotionCommand              = gameObject.AddComponent <BTDyingMotionBossCommand>();
        m_diedCommand               = gameObject.AddComponent <BTDiedBossCommand>();
        m_instanceEnemy2Command     = gameObject.AddComponent <BTInstanceEnemyBossCommand>();
        m_waiting3Command           = gameObject.AddComponent <BTWaitingCommand>();
        m_stompCommand              = gameObject.AddComponent <BTStompBossCommand>();
        m_upDownCrabScissorsCommand = gameObject.AddComponent <BTUpDownCrabScissorsBossCommand>();
        m_seaWavyCommand            = gameObject.AddComponent <BTSeaWavyBossCommand>();
        m_meteoWithWaterGunCommand  = gameObject.AddComponent <BTMeteoWithWaterGunBossCommand>();
        m_waiting4Command           = gameObject.AddComponent <BTWaitingCommand>();

        //Conditionの生成
        m_isHealthHalfDownCondition = gameObject.AddComponent <BTIsHealthHalfDownCondition>();
        m_isDyingCondition          = gameObject.AddComponent <BTIsDyingBossCondition>();
        m_isAfterDyingCondition     = gameObject.AddComponent <BTIsAfterDyingCondition>();

        //Commandの初期化
        m_angryMotionCommand.Initialize(this.gameObject);
        m_playerObserverCommand.Initialize(this.gameObject);
        m_inkSpewCommand.Initialize(this.gameObject);
        m_instanceEnemyCommand.Initialize(this.gameObject);
        m_waitingCommand.Initialize(3);
        m_rotationAttackCommand.Initialize(this.gameObject);
        m_crabScissorsCommand.Initialize(this.gameObject);
        m_momentMaulCommand.Initialize(this.gameObject);
        m_separateContinuousAttackCommand.Initialize(this.gameObject);
        m_fireBallPreventingEscapeCommand.Initialize(this.gameObject);
        m_waiting2Command.Initialize(0.1f);
        m_dyingMotionCommand.Initialize(this.gameObject);
        m_diedCommand.Initialize(this.gameObject);
        m_instanceEnemy2Command.Initialize(this.gameObject);
        m_waiting3Command.Initialize(2);
        m_stompCommand.Initialize(this.gameObject);
        m_upDownCrabScissorsCommand.Initialize(this.gameObject);
        m_seaWavyCommand.Initialize(this.gameObject);
        m_meteoWithWaterGunCommand.Initialize(this.gameObject);
        m_waiting4Command.Initialize(0.1f);

        //Conditionの初期化
        m_isHealthHalfDownCondition.Initialize(this.gameObject);
        m_isDyingCondition.Initialize(this.gameObject);
        m_isAfterDyingCondition.Initialize(this.gameObject);


        //Nodeの生成・初期化・連結
        //前半のBT
        //third1
        m_rotationAttackNode           = new BTActionNode(m_rotationAttackCommand);
        m_crabScissorsNode             = new BTActionNode(m_crabScissorsCommand);
        m_momentMaulNode               = new BTActionNode(m_momentMaulCommand);
        m_separateContinuousAttackNode = new BTActionNode(m_separateContinuousAttackCommand);
        m_fireBallPreventingEscapeNode = new BTActionNode(m_fireBallPreventingEscapeCommand);

        //second1
        m_angryMotionNode    = new BTActionNode(m_angryMotionCommand);
        m_playerObserverNode = new BTActionNode(m_playerObserverCommand);
        m_inkSpewNode        = new BTActionNode(m_inkSpewCommand);

        //second2
        m_instanceEnemyNode = new BTActionNode(m_instanceEnemyCommand);
        m_waitingNode       = new BTActionNode(m_waitingCommand);
        List <BaseBTNode> randomAttack = new List <BaseBTNode>();

        randomAttack.Add(m_rotationAttackNode);
        randomAttack.Add(m_crabScissorsNode);
        randomAttack.Add(m_momentMaulNode);
        randomAttack.Add(m_fireBallPreventingEscapeNode);
        m_randomAttackNode = new BTOnOffSelector(randomAttack);
        m_waiting2Node     = new BTActionNode(m_waiting2Command);

        //first1
        m_isHealthHalfDownNode = new BTConditionNotToEnd(m_isHealthHalfDownCondition);
        List <BaseBTNode> halfMotion = new List <BaseBTNode>();

        halfMotion.Add(m_angryMotionNode);
        halfMotion.Add(m_playerObserverNode);
        halfMotion.Add(m_inkSpewNode);
        m_halfMotionNode = new BTSequence(halfMotion);
        List <BaseBTNode> commonAction = new List <BaseBTNode>();

        commonAction.Add(m_instanceEnemyNode);
        commonAction.Add(m_waitingNode);
        commonAction.Add(m_randomAttackNode);
        commonAction.Add(m_waiting2Node);
        m_commonActionNode = new BTSequence(commonAction);

        //root
        m_rootNode = new BTTEandNTEBoolSelector(m_halfMotionNode, m_commonActionNode,
                                                m_isHealthHalfDownNode);

        //後半のBT
        //fourth
        m_stompNode = new BTActionNode(m_stompCommand);
        m_upDownCrabScissorsNode = new BTActionNode(m_upDownCrabScissorsCommand);
        m_seaWavyNode            = new BTActionNode(m_seaWavyCommand);
        m_meteoWithWaterGunNode  = new BTActionNode(m_meteoWithWaterGunCommand);

        //third1
        List <BaseBTNode> newRandomAttack = new List <BaseBTNode>();

        newRandomAttack.Add(m_stompNode);
        m_randomAttackNode2 = new BTOnOffSelector(randomAttack);

        //second1
        m_isAfterDyingNode = new BTConditionToEnd(m_isAfterDyingCondition);
        m_dyingMotionNode  = new BTActionNode(m_dyingMotionCommand);
        m_diedNode         = new BTActionNode(m_diedCommand);

        //second2
        m_instanceEnemyNode2 = new BTActionNode(m_instanceEnemy2Command);
        m_waiting3Node       = new BTActionNode(m_waiting3Command);
        List <BaseBTNode> twoSelection = new List <BaseBTNode>();

        twoSelection.Add(m_randomAttackNode);
        twoSelection.Add(m_randomAttackNode2);
        m_randomTwoSelectionAttack = new BTOnOffSelector(twoSelection);
        m_waiting4Node             = new BTActionNode(m_waiting4Command);

        //first1
        m_isDyingNode    = new BTConditionNotToEnd(m_isDyingCondition);
        m_afterDyingNode = new BTBoolSelector(m_diedNode, m_dyingMotionNode,
                                              m_isAfterDyingNode);
        List <BaseBTNode> commonAction2 = new List <BaseBTNode>();

        commonAction2.Add(m_instanceEnemyNode2);
        commonAction2.Add(m_waiting3Node);
        commonAction2.Add(m_randomAttackNode);
        commonAction2.Add(m_waiting4Node);
        m_commonActionNode2 = new BTSequence(commonAction2);

        //root
        m_rootNode2 = new BTTEandNTEBoolSelector(m_afterDyingNode, m_commonActionNode2,
                                                 m_isDyingNode);

        status              = GetComponent <BossStatus>();
        movePosition        = new Vector3[4];
        lookAtPosition      = new Vector3[4];
        isHealthHalfDown    = false;
        isPreHealthHalfDown = false;
    }
    private float speed;            //スピード

    //初期化処理
    void Start()
    {
        //Commandの生成
        m_nockBackingCommand          = this.gameObject.AddComponent <BTNockBackingCommand>();
        m_dyingCommand                = this.gameObject.AddComponent <BTDyingCommand>();
        m_flownDamageWaitingCommand   = this.gameObject.AddComponent <BTWaitingCommand>();
        m_findingReactionCommand      = this.gameObject.AddComponent <BTFindingReactionCommand>();
        m_runningAwayCommand          = this.gameObject.AddComponent <BTRunningAwayCommand>();
        m_forwardSwingWaitingCommand  = this.gameObject.AddComponent <BTWaitingCommand>();
        m_shootingCommand             = this.gameObject.AddComponent <BTShootingCommand>();
        m_followThroughWaitingCommand = this.gameObject.AddComponent <BTWaitingCommand>();
        m_wanderingWaitingCommand     = this.gameObject.AddComponent <BTWaitingCommand>();
        m_wanderingCommand            = this.gameObject.AddComponent <BTWanderingCommand>();

        //Conditionの生成
        m_isFlownAttackedCondition = this.gameObject.AddComponent <BTIsFlownAttackedCondition>();
        m_isDyingCondition         = this.gameObject.AddComponent <BTIsDyingCondition>();
        m_isFindingPlayerCondition = this.gameObject.AddComponent <BTIsFindingPlayerCondition>();

        //Commandの初期化
        m_nockBackingCommand.Initialize(this.gameObject);
        m_dyingCommand.Initialize(this.gameObject);
        m_flownDamageWaitingCommand.Initialize(0.1f);
        m_findingReactionCommand.Initialize(this.gameObject);
        m_runningAwayCommand.Initialize(this.gameObject);
        m_forwardSwingWaitingCommand.Initialize(1);
        m_shootingCommand.Initialize(this.gameObject);
        m_followThroughWaitingCommand.Initialize(1);
        m_wanderingWaitingCommand.Initialize(3);
        m_wanderingCommand.Initialize(this.gameObject);

        //Conditionの初期化
        m_isFlownAttackedCondition.Initialize(this.gameObject);
        m_isDyingCondition.Initialize(this.gameObject);
        m_isFindingPlayerCondition.Initialize(this.gameObject);


        //Nodeの生成・初期化・連結
        //third1
        m_isDyingNode            = new BTConditionToEnd(m_isDyingCondition);
        m_dyingNode              = new BTActionNode(m_dyingCommand);
        m_flownDamageWaitingNode = new BTActionNode(m_flownDamageWaitingCommand);

        //third2
        m_findingReactionNode     = new BTActionNode(m_findingReactionCommand);
        m_runningAwayNode         = new BTActionNode(m_runningAwayCommand);
        m_forwardSwingWaitingNode = new BTActionNode(m_forwardSwingWaitingCommand);
        m_shootingNode            = new BTActionNode(m_shootingCommand);
        m_followThroughNode       = new BTActionNode(m_followThroughWaitingCommand);

        //third3
        m_wanderingNode        = new BTActionNode(m_wanderingCommand);
        m_wanderingWaitingNode = new BTActionNode(m_wanderingWaitingCommand);

        //second1
        m_nockBackingNode   = new BTActionNode(m_nockBackingCommand);
        m_afterNockBackNode = new BTBoolSelector(m_dyingNode, m_flownDamageWaitingNode, m_isDyingNode);

        //second2
        m_nockBackingNode   = new BTActionNode(m_nockBackingCommand);
        m_afterNockBackNode = new BTBoolSelector(m_dyingNode, m_flownDamageWaitingNode, m_isDyingNode);

        //second3
        m_isFindingPlayerNode = new BTConditionNotToEnd(m_isFindingPlayerCondition);
        List <BaseBTNode> attackFlow = new List <BaseBTNode>();

        attackFlow.Add(m_runningAwayNode);
        attackFlow.Add(m_forwardSwingWaitingNode);
        attackFlow.Add(m_shootingNode);
        attackFlow.Add(m_followThroughNode);
        m_attackFlowingNode = new BTSequence(attackFlow);
        List <BaseBTNode> wanderFlow = new List <BaseBTNode>();

        wanderFlow.Add(m_wanderingNode);
        wanderFlow.Add(m_wanderingWaitingNode);
        m_wanderFlowingNode = new BTSequence(wanderFlow);

        //first
        m_isFlownAttackedNode = new BTConditionNotToEnd(m_isFlownAttackedCondition);
        List <BaseBTNode> isFlownAttackedList = new List <BaseBTNode>();

        isFlownAttackedList.Add(m_nockBackingNode);
        isFlownAttackedList.Add(m_afterNockBackNode);
        m_damageExpressionNode = new BTSequence(isFlownAttackedList);
        m_commonActionNode     = new BTBoolSelector(m_attackFlowingNode, m_wanderFlowingNode, m_isFindingPlayerNode);

        //root
        m_rootNode = new BTTEandNTEBoolSelector(m_damageExpressionNode, m_commonActionNode,
                                                m_isFlownAttackedNode);

        status = GetComponent <EnemyStatus>();
        status.SetEnemyType(EnemyType.Shooter);

        speed = 0;
    }