//-----------------------------------------------------
    // 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;
    }
Esempio n. 2
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;
    }
Esempio n. 3
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;
    }
Esempio n. 4
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;
    }