Ejemplo n.º 1
0
 private static void BehaviourLoaded(BehaviourBase behaviour, MemberInfo info)
 {
     if (behaviour is CustomConstructorAttribute constructor && info is MethodInfo method)
     {
         CustomConstructorLoaded(constructor, method);
     }
 }
Ejemplo n.º 2
0
    //--------------------------------------------------------------------------------------
    //Update behaviours in tree - AND like
    //
    // Return:
    //		Returns a enum BehaviourStatus, current status of behaviour, Success, failed, pending
    //--------------------------------------------------------------------------------------
    public override BehaviourBase.BehaviourStatus Execute()
    {
        if (!m_pendingBranch)
        {
            BehaviourSetup();
        }

        //Requires only one child to succeed
        while (m_branchNumber < m_behaviourBranches.Count)
        {
            BehaviourBase currentBranch = m_behaviourBranches[m_branchNumber];

            if (!m_pendingBranch)
            {
                currentBranch.BehaviourSetup();
            }
            m_pendingBranch = false;
            BehaviourBase.BehaviourStatus branchStatus = currentBranch.Execute();

            if (branchStatus == BehaviourStatus.FAILURE)
            {
                return(BehaviourStatus.FAILURE);
            }
            if (branchStatus == BehaviourStatus.PENDING)
            {
                m_pendingBranch = true;
                return(BehaviourStatus.PENDING);
            }
            m_branchNumber++;
        }
        return(BehaviourStatus.SUCCESS);
    }
Ejemplo n.º 3
0
        public static MessageArrivedEx Send(int messageID, BehaviourBase followPath)
        {
            var msg = pool.New();

            msg.Init(messageID, followPath);
            MessageManager.GetInstance().Send(msg);
            return(msg);
        }
Ejemplo n.º 4
0
        //----------------------------------------------------------
        #region パブリック関数
        //----------------------------------------------------------

        /// <summary>
        /// コンストラクタ
        /// </summary>
        internal Sound(BehaviourBase behaviour, Resource res, AudioSource[] sources)
        {
            Assert.IsNotNull(res);
            Assert.IsNotNull(sources);

            cRes       = res;
            cSources   = new AudioSource[cTrackNum];
            cPlayingId = new int[cTrackBgmNum];
            cPausingId = new int[cTrackBgmNum];

            foreach (var s in sources)
            {
                if (s.outputAudioMixerGroup == null)
                {
                    continue;
                }

                int track;
                switch (s.outputAudioMixerGroup.name)
                {
                case "BGM1": track = (int)ESoundTrack.BGM1; break;

                case "BGM2": track = (int)ESoundTrack.BGM2; break;

                case "BGM3": track = (int)ESoundTrack.BGM3; break;

                case "SE": track = (int)ESoundTrack.SE; break;

                default: continue;
                }

                initSource(s);
                cSources[track] = s;
            }

            // コンポーネントが足りなければ足す
            for (var i = 0; i < cTrackNum; i++)
            {
                if (cSources[i] != null)
                {
                    continue;
                }

                cSources[i] = behaviour.gameObject.AddComponent <AudioSource>();
                initSource(cSources[i]);

                var trackName = ((ESoundTrack)i).ToString();
                var candidate = cRes.AudioMixer.FindMatchingGroups(trackName);
                Assert.IsTrue(candidate.Length == 1);
                cSources[i].outputAudioMixerGroup = candidate[0];
            }

            Reset();
        }
    //-----------------------------------------------------
    // Setting up all AI behaviour components
    //
    // Just move towards player
    //-----------------------------------------------------
    void Start()
    {
        //Set up varibles
        m_sequenceTop  = gameObject.AddComponent <BehaviourSequence>();
        m_sequenceMove = gameObject.AddComponent <BehaviourSequence>();

        m_actionGetDisMovement = gameObject.AddComponent <IsTargetCloseEnough>();
        m_actionMovetowards    = gameObject.AddComponent <MoveTowardsTarget>();

        m_actionGetTarget = gameObject.AddComponent <GetTargetSinglePlayer>();


        //Movement
        m_actionGetDisMovement.m_targetDistance = m_moveTowardsRange;

        //Set up branches
        m_sequenceTop.m_behaviourBranches.Add(m_actionGetTarget as BehaviourBase);
        m_sequenceTop.m_behaviourBranches.Add(m_sequenceMove);

        m_sequenceMove.m_behaviourBranches.Add(m_actionGetDisMovement);
        m_sequenceMove.m_behaviourBranches.Add(m_actionMovetowards);

        m_initalBehaviour = m_sequenceTop;
    }
Ejemplo n.º 6
0
    //-----------------------------------------------------
    // Setting up all AI behaviour components
    //
    // Move towards player, fire gun, repeat
    //-----------------------------------------------------
    void Start()
    {
        //Set health
        SetHealth(m_healthMax);

        //Set up varibles
        m_sequenceTop = gameObject.AddComponent <BehaviourSequence>();

        m_selectorActions = gameObject.AddComponent <BehaviourSelector>();

        //m_sequenceLaser = gameObject.AddComponent<BehaviourSequence>();
        m_sequenceGun  = gameObject.AddComponent <BehaviourSequence>();
        m_sequenceMove = gameObject.AddComponent <BehaviourSequence>();

        //m_actionGetDisLaser = gameObject.AddComponent<IsTargetCloseEnough>();
        //m_actionFireLaser = gameObject.AddComponent<FireLaserbeam>();
        //m_actionLaserCooldown = gameObject.AddComponent<CoolDown>();

        m_selectorFiringGun = gameObject.AddComponent <BehaviourSelector>();

        m_actionGetDisGun      = gameObject.AddComponent <IsTargetCloseEnough>();
        m_actionInfrontOfLedge = gameObject.AddComponent <InfrontOfLedge>();
        m_actionStopMovement   = gameObject.AddComponent <StopMovement>();

        m_actionFireGun     = gameObject.AddComponent <FireGun>();
        m_actionGunCooldown = gameObject.AddComponent <CoolDown>();

        m_actionGetDisMovement = gameObject.AddComponent <IsTargetCloseEnough>();
        m_actionMovetowards    = gameObject.AddComponent <MoveTowardsTarget>();

        //Set up get target
        if (GameObject.FindWithTag("GameController").GetComponent <GameManager>().m_singlePlayer)
        {
            m_actionGetTarget = gameObject.AddComponent <GetTargetSinglePlayer>();
        }
        else
        {
            switch (m_difficulty)
            {
            case Difficulty.Easy:
            {
                m_actionGetTarget = gameObject.AddComponent <GetTargetEasy>();
                break;
            }

            case Difficulty.Medium:
            {
                m_actionGetTarget = gameObject.AddComponent <GetTargetMedium>();
                break;
            }

            case Difficulty.Hard:
            {
                m_actionGetTarget = gameObject.AddComponent <GetTargetHard>();
                break;
            }
            }
        }

        //Gun
        m_actionGetDisGun.m_targetDistance = m_gunFireDistance;
        m_actionFireGun.m_numberOfBullets  = m_gunNumberOfShots;
        m_actionFireGun.m_timeBetweenShots = m_gunTimeBetweenShots;
        m_actionFireGun.m_bulletSpeed      = m_gunBulletSpeed;
        m_actionFireGun.m_bulletSpawnPos   = m_bulletSpawnPos;
        m_actionGunCooldown.m_coolDown     = m_gunCooldown;

        m_actionFireGun.m_bullet = m_bulletPrefab;

        //Laser
        //m_actionGetDisLaser.m_targetDistance = m_laserFireDistance;
        //m_actionFireLaser.m_chargeRate = m_laserChargeTime;
        //m_actionLaserCooldown.m_coolDown = m_laserCooldown;

        //m_actionFireLaser.m_laserbeam = m_laserPrefab;

        //Movement
        m_actionGetDisMovement.m_targetDistance = m_moveTowardsRange;

        //Set up branches
        m_sequenceTop.m_behaviourBranches.Add(m_actionGetTarget as BehaviourBase);
        m_sequenceTop.m_behaviourBranches.Add(m_selectorActions);

        //m_selectorActions.m_behaviourBranches.Add(m_sequenceLaser);
        m_selectorActions.m_behaviourBranches.Add(m_sequenceGun);
        m_selectorActions.m_behaviourBranches.Add(m_sequenceMove);

        //m_sequenceLaser.m_behaviourBranches.Add(m_actionGetDisLaser);
        //m_sequenceLaser.m_behaviourBranches.Add(m_actionFireLaser);
        //m_sequenceLaser.m_behaviourBranches.Add(m_actionLaserCooldown);

        m_selectorFiringGun.m_behaviourBranches.Add(m_actionGetDisGun);
        m_selectorFiringGun.m_behaviourBranches.Add(m_actionInfrontOfLedge);

        m_sequenceGun.m_behaviourBranches.Add(m_selectorFiringGun);
        m_sequenceGun.m_behaviourBranches.Add(m_actionStopMovement);
        m_sequenceGun.m_behaviourBranches.Add(m_actionFireGun);
        m_sequenceGun.m_behaviourBranches.Add(m_actionGunCooldown);

        m_sequenceMove.m_behaviourBranches.Add(m_actionGetDisMovement);
        m_sequenceMove.m_behaviourBranches.Add(m_actionMovetowards);

        m_initalBehaviour = m_sequenceTop;
    }
Ejemplo n.º 7
0
    //-----------------------------------------------------
    // Setting up all AI behaviour components
    //
    // Jump across platforms, fire laser at player, jump to new platform
    //-----------------------------------------------------
    void Start()
    {
        //Set health
        SetHealth(m_healthMax);

        m_selectorTop = gameObject.AddComponent <BehaviourSelector>();

        m_gettingTarget  = gameObject.AddComponent <BehaviourSequence>();
        m_selectorAction = gameObject.AddComponent <BehaviourSelector>();
        m_sequenceFiring = gameObject.AddComponent <BehaviourSequence>();
        m_sequenceLaser  = gameObject.AddComponent <BehaviourSequence>();

        //Laser
        m_actionGetDisLaser   = gameObject.AddComponent <IsTargetCloseEnough>();
        m_actionFireLaser     = gameObject.AddComponent <FireLaserbeam>();
        m_actionLaserCooldown = gameObject.AddComponent <CoolDown>();

        m_jumpToPlatform  = gameObject.AddComponent <JumpToPlatform>();
        m_landingCooldown = gameObject.AddComponent <CoolDown>();

        //Set up get target
        if (GameObject.FindWithTag("GameController").GetComponent <GameManager>().m_singlePlayer)
        {
            m_actionGetTarget = gameObject.AddComponent <GetTargetSinglePlayer>();
        }
        else
        {
            switch (m_difficulty)
            {
            case Difficulty.Easy:
            {
                m_actionGetTarget = gameObject.AddComponent <GetTargetEasy>();
                break;
            }

            case Difficulty.Medium:
            {
                m_actionGetTarget = gameObject.AddComponent <GetTargetMedium>();
                break;
            }

            case Difficulty.Hard:
            {
                m_actionGetTarget = gameObject.AddComponent <GetTargetHard>();
                break;
            }
            }
        }

        m_selectorTop.m_behaviourBranches.Add(m_gettingTarget);
        m_selectorTop.m_behaviourBranches.Add(m_jumpToPlatform);

        m_gettingTarget.m_behaviourBranches.Add(m_actionGetTarget as BehaviourBase);
        m_gettingTarget.m_behaviourBranches.Add(m_selectorAction);

        m_selectorAction.m_behaviourBranches.Add(m_sequenceFiring);

        m_sequenceFiring.m_behaviourBranches.Add(m_sequenceLaser);
        m_sequenceFiring.m_behaviourBranches.Add(m_jumpToPlatform);
        m_sequenceFiring.m_behaviourBranches.Add(m_landingCooldown);

        m_sequenceLaser.m_behaviourBranches.Add(m_actionGetDisLaser);
        m_sequenceLaser.m_behaviourBranches.Add(m_actionFireLaser);
        m_sequenceLaser.m_behaviourBranches.Add(m_actionLaserCooldown);
        m_sequenceLaser.m_behaviourBranches.Add(m_jumpToPlatform);

        //Laser
        m_actionGetDisLaser.m_targetDistance  = m_laserFireDistance;
        m_actionFireLaser.m_chargeRate        = m_laserChargeTime;
        m_actionFireLaser.m_laserSpawnPos     = m_laserPos;
        m_actionFireLaser.m_laserFriendlyFire = m_laserFriendlyFire;
        m_actionFireLaser.m_laserFollowing    = m_laserFollowing;

        m_actionLaserCooldown.m_coolDown = m_laserCooldown;

        m_actionFireLaser.m_laserbeam = m_laserPrefab;

        //Jumping
        m_jumpToPlatform.m_jumpHeight = m_jumpHeight;
        m_jumpToPlatform.m_jumpTime   = m_jumpTime;

        m_landingCooldown.m_coolDown = m_landingTimer;

        m_initalBehaviour = m_selectorTop;
    }
Ejemplo n.º 8
0
        //----------------------------------------------------------
        #region パブリック関数
        //----------------------------------------------------------

        /// <summary>
        /// コンストラクタ
        /// </summary>
        internal Network(BehaviourBase behaviour, Graphic graphic)
        {
            cBehaviour = behaviour;
            cGraphic   = graphic;
            cCache     = new Dictionary <string, object>();
        }
Ejemplo n.º 9
0
    //-----------------------------------------------------
    // Setting up all AI behaviour components
    //
    // Fire left claw, fire right and laser at same time
    //-----------------------------------------------------
    void Start()
    {
        //Set health
        SetHealth(m_healthMax);

        m_sequenceTop = gameObject.AddComponent <BehaviourSequence>();

        m_firingParallel = gameObject.AddComponent <BehaviourParallel>();

        m_sequenceLeftGun  = gameObject.AddComponent <BehaviourSequence>();
        m_sequenceRightGun = gameObject.AddComponent <BehaviourSequence>();
        m_sequenceLaser    = gameObject.AddComponent <BehaviourSequence>();

        m_actionGetTarget = gameObject.AddComponent <BehaviourBase>();

        //LeftClaw
        m_actionFireLeftGun = gameObject.AddComponent <FireGun>();

        //RightClaw
        m_actionFireRightGun = gameObject.AddComponent <FireGun>();

        //Both Claws
        m_actionGetDisGun   = gameObject.AddComponent <IsTargetCloseEnough>();
        m_actionGunCooldown = gameObject.AddComponent <CoolDown>();

        //Laser
        m_actionGetDisLaser   = gameObject.AddComponent <IsTargetCloseEnough>();
        m_actionFireLaser     = gameObject.AddComponent <FireLaserbeam>();
        m_actionLaserCooldown = gameObject.AddComponent <CoolDown>();

        //Set up get target
        if (GameObject.FindWithTag("GameController").GetComponent <GameManager>().m_singlePlayer)
        {
            m_actionGetTarget = gameObject.AddComponent <GetTargetSinglePlayer>();
        }
        else
        {
            switch (m_difficulty)
            {
            case Difficulty.Easy:
            {
                m_actionGetTarget = gameObject.AddComponent <GetTargetEasy>();
                break;
            }

            case Difficulty.Medium:
            {
                m_actionGetTarget = gameObject.AddComponent <GetTargetMedium>();
                break;
            }

            case Difficulty.Hard:
            {
                m_actionGetTarget = gameObject.AddComponent <GetTargetHard>();
                break;
            }
            }
        }

        //Left gun
        m_actionGetDisGun.m_targetDistance     = m_gunFireDistance;
        m_actionFireLeftGun.m_numberOfBullets  = m_gunNumberOfShots;
        m_actionFireLeftGun.m_timeBetweenShots = m_gunTimeBetweenShots;
        m_actionFireLeftGun.m_bulletSpeed      = m_gunBulletSpeed;
        m_actionFireLeftGun.m_bulletSpawnPos   = m_leftClawPos;
        m_actionFireLeftGun.m_bullet           = m_bulletPrefab;
        m_actionGunCooldown.m_coolDown         = m_gunCooldown;


        //Right gun
        m_actionGetDisGun.m_targetDistance      = m_gunFireDistance;
        m_actionFireRightGun.m_numberOfBullets  = m_gunNumberOfShots;
        m_actionFireRightGun.m_timeBetweenShots = m_gunTimeBetweenShots;
        m_actionFireRightGun.m_bulletSpeed      = m_gunBulletSpeed;
        m_actionFireRightGun.m_bulletSpawnPos   = m_rightClawPos;
        m_actionFireRightGun.m_bullet           = m_bulletPrefab;
        m_actionGunCooldown.m_coolDown          = m_gunCooldown;

        //Laser
        m_actionGetDisLaser.m_targetDistance  = m_laserFireDistance;
        m_actionFireLaser.m_chargeRate        = m_laserChargeTime;
        m_actionFireLaser.m_laserSpawnPos     = m_laserPos;
        m_actionFireLaser.m_laserFriendlyFire = m_laserFriendlyFire;
        m_actionFireLaser.m_laserFollowing    = m_laserFollowing;
        m_actionFireLaser.m_laserbeam         = m_laserPrefab;

        m_actionLaserCooldown.m_coolDown = m_laserCooldown;

        //Set up branches
        m_sequenceTop.m_behaviourBranches.Add(m_actionGetTarget as BehaviourBase);
        m_sequenceTop.m_behaviourBranches.Add(m_sequenceLeftGun);
        m_sequenceTop.m_behaviourBranches.Add(m_firingParallel);

        m_firingParallel.m_behaviourBranches.Add(m_sequenceLaser);
        m_firingParallel.m_behaviourBranches.Add(m_sequenceRightGun);

        m_sequenceLeftGun.m_behaviourBranches.Add(m_actionGetDisGun);
        m_sequenceLeftGun.m_behaviourBranches.Add(m_actionFireLeftGun);
        m_sequenceLeftGun.m_behaviourBranches.Add(m_actionGunCooldown);

        m_sequenceRightGun.m_behaviourBranches.Add(m_actionGetDisGun);
        m_sequenceRightGun.m_behaviourBranches.Add(m_actionFireRightGun);
        m_sequenceRightGun.m_behaviourBranches.Add(m_actionGunCooldown);

        m_sequenceLaser.m_behaviourBranches.Add(m_actionGetDisLaser);
        m_sequenceLaser.m_behaviourBranches.Add(m_actionFireLaser);
        m_sequenceLaser.m_behaviourBranches.Add(m_actionLaserCooldown);

        m_initalBehaviour = m_sequenceTop;
    }
Ejemplo n.º 10
0
 public void AddBehaviour(BehaviourBase behaviour)
 {
     behaviours.Add(behaviour);
 }
Ejemplo n.º 11
0
 public void Init(int messageID, BehaviourBase followPath)
 {
     this.messageID  = messageID;
     this.followPath = followPath;
 }
Ejemplo n.º 12
0
 public override void OnDeathToPool()
 {
     this.followPath = null;
 }
Ejemplo n.º 13
0
 public void AddBranch(BehaviourBase behaviour)
 {
     m_behaviourBranches.Add(behaviour);
 }
Ejemplo n.º 14
0
    //-----------------------------------------------------
    // Setting up all AI behaviour components
    //
    // Fly towards, fire in a cone, flee, repeat
    //-----------------------------------------------------
    void Start()
    {
        //Set health
        SetHealth(m_healthMax);

        //Set up varibles
        m_sequenceTop = gameObject.AddComponent <BehaviourSequence>();

        m_selectorActions = gameObject.AddComponent <BehaviourSelector>();

        m_sequenceCone = gameObject.AddComponent <BehaviourSequence>();
        m_sequenceMove = gameObject.AddComponent <BehaviourSequence>();

        m_actionGetDisCone   = gameObject.AddComponent <IsTargetCloseEnoughX>();
        m_actionFireCone     = gameObject.AddComponent <FireCone> ();
        m_actionFlee         = gameObject.AddComponent <FleeTarget> ();
        m_actionConeCooldown = gameObject.AddComponent <CoolDown> ();

        m_actionGetDisMovement = gameObject.AddComponent <IsTargetCloseEnoughX> ();
        m_actionMovetowards    = gameObject.AddComponent <MoveTowardsTargetFlying> ();

        //Set up get target
        if (GameObject.FindWithTag("GameController").GetComponent <GameManager>().m_singlePlayer)
        {
            m_actionGetTarget = gameObject.AddComponent <GetTargetSinglePlayer>();
        }
        else
        {
            switch (m_difficulty)
            {
            case Difficulty.Easy:
            {
                m_actionGetTarget = gameObject.AddComponent <GetTargetEasy>();
                break;
            }

            case Difficulty.Medium:
            {
                m_actionGetTarget = gameObject.AddComponent <GetTargetMedium>();
                break;
            }

            case Difficulty.Hard:
            {
                m_actionGetTarget = gameObject.AddComponent <GetTargetHard>();
                break;
            }
            }
        }

        //Cone
        m_actionGetDisCone.m_targetDistance = m_coneFireDistance;

        m_actionFireCone.m_numberOfBullets  = m_coneNumberOfBursts;
        m_actionFireCone.m_timeBetweenShots = m_coneTimeBetweenShots;
        m_actionFireCone.m_bulletSpeed      = m_coneBulletSpeed;
        m_actionFireCone.m_fireCone         = m_coneAngle;
        m_actionFireCone.m_maxDis           = m_coneFireDistance + 1;
        m_actionFireCone.m_bulletSpawnPos   = m_bulletSpawnPos;

        m_actionFlee.m_fleeDistance    = m_fleeDistance;
        m_actionFlee.m_maxFleeDuration = m_fleeMaxTime;

        m_actionConeCooldown.m_coolDown = m_coneCooldown;

        m_actionFireCone.m_bullet = m_bulletPrefab;

        //Movement
        m_actionGetDisMovement.m_targetDistance = m_moveTowardsRange;

        //Set up branches
        m_sequenceTop.m_behaviourBranches.Add(m_actionGetTarget as BehaviourBase);
        m_sequenceTop.m_behaviourBranches.Add(m_selectorActions);

        m_selectorActions.m_behaviourBranches.Add(m_sequenceCone);
        m_selectorActions.m_behaviourBranches.Add(m_sequenceMove);

        m_sequenceCone.m_behaviourBranches.Add(m_actionGetDisCone);
        m_sequenceCone.m_behaviourBranches.Add(m_actionFireCone);
        m_sequenceCone.m_behaviourBranches.Add(m_actionFlee);
        m_sequenceCone.m_behaviourBranches.Add(m_actionConeCooldown);

        m_sequenceMove.m_behaviourBranches.Add(m_actionGetDisMovement);
        m_sequenceMove.m_behaviourBranches.Add(m_actionMovetowards);

        m_initalBehaviour = m_sequenceTop;

        //Always play wasp movement sounds
        if (m_movementAudio != null)
        {
            m_movementAudio.GetComponent <AudioSource> ().Play();
        }
    }