Example #1
0
 private void SetupDashTimer()
 {
     dashTimer = gameObject.AddComponent <IntervalTimerComponent>();
     dashTimer.SetInterval(CooldownTime);
     dashTimer.AutoReset = false;
     dashTimer.OnIntervalReached.AddListener(OnIntervalReached);
 }
Example #2
0
 private void SetupTimers()
 {
     ShootTimer = gameObject.AddComponent <IntervalTimerComponent>();
     ShootTimer.SetInterval(SHOOT_COOLDOWN);
     ShootTimer.IsActive  = true;
     ShootTimer.AutoReset = false;
 }
        public void PhaseBegin(ILevelContext context)
        {
            flyingVFormationPrefab = ComponentBase.GetRequiredResource <GameObject>($"{ResourcePaths.PrefabsFolder}/Actors/Formations/{GameObjects.Formations.FlyingV}");

            GameObject asteroidPrefab = ComponentBase.GetRequiredResource <GameObject>($"{ResourcePaths.PrefabsFolder}/Projectiles/{GameObjects.Projectiles.Asteroid}");

            // Create an asteroid spawner which will generate a random asteroid ever buncha milliseconds
            asteroidSpawner = ComponentBase.InstantiateInLevel("AsteroidSpawner", Vector3.zero, typeof(AutoSpawnerComponent));
            ComponentBase.GetRequiredComponent <AutoSpawnerComponent>(asteroidSpawner).Initialize(500, asteroidPrefab);

            // This method is used to spawn enemies, initialize the phase, etc
            GameObject enemy = ComponentBase.GetRequiredResource <GameObject>($"{ResourcePaths.PrefabsFolder}/Actors/Enemies/Shooter_AI");

            GameObject inst = ComponentBase.InstantiateInLevel(enemy);

            inst.transform.position = new Vector3(-2, 3f, 3);
            GameObject inst2 = ComponentBase.InstantiateInLevel(enemy);

            inst2.transform.position = new Vector3(2, 3, 4);

            // A formation will spawn after a while
            intervalTimerObject = new GameObject("FormationSpawnTimer");

            intervalTimerObject.AddComponent <IntervalTimerComponent>();
            IntervalTimerComponent timer = ComponentBase.GetRequiredComponent <IntervalTimerComponent>(intervalTimerObject);

            timer.SetInterval(3000);
            timer.OnIntervalReached.AddListener(SpawnFormation);
            timer.SelfDestruct = true;
            timer.IsActive     = true;

            // Play some dank tunes
            ComponentBase.GetMusicPlayer().Loop(MusicPlayerComponent.Song.Prototype);
        }
Example #4
0
        public override void ComponentStart()
        {
            var brain = GetRequiredComponent <HumanoidNPCBrainComponent>();

            brain.attackByPlayer.AddListener(OnAttackedByPlayer);
            brain.attackBegin.AddListener(OnAttackBegin);
            brain.attackEnd.AddListener(OnAttackEnd);
            brain.damageEnable.AddListener(OnDamageEnable);
            brain.damageDisable.AddListener(OnDamageDisable);

            var brainTimerPrefabTemp = new GameObject();

            brainTimerPrefabTemp.AddComponent <IntervalTimerComponent>();
            var inst = Instantiate(brainTimerPrefabTemp, transform);

            inst.name = "BrainTimer";

            brainTimer       = GetRequiredComponent <IntervalTimerComponent>(inst);
            brainTimer.Label = "BrainTimerComponent";
            brainTimer.SetInterval((int)UnityEngine.Random.Range(thinkTimeMin, thinkTimeMax));
            brainTimer.SelfDestruct = false;
            brainTimer.Randomize    = false;
            brainTimer.AutoReset    = true;
            brainTimer.OnIntervalReached.AddListener(BrainUpdate);

            Destroy(brainTimerPrefabTemp);
            base.ComponentStart();
        }
        public override void ComponentAwake()
        {
            intervalTimerComponent = GetRequiredComponent <IntervalTimerComponent>();
            intervalTimerComponent.OnIntervalReached.AddListener(TimerComplete);
            spawnQueue = new Queue <Spawn>(Spawns);

            base.ComponentAwake();
        }
Example #6
0
 // Initialize and attach all Interval Timer Components
 private void CreateTimers()
 {
     shootTimer = gameObject.AddComponent <IntervalTimerComponent>();
     shootTimer.SetInterval(shotDelay);
     shootTimer.AutoReset = true;
     shootTimer.Randomize = true;
     shootTimer.OnIntervalReached.AddListener(ShotTimerReached);
     shootTimer.IsActive = true;
 }
Example #7
0
 private void CreateTimers()
 {
     lifeTimer = gameObject.AddComponent <IntervalTimerComponent>();
     lifeTimer.SetInterval(lifetime);
     lifeTimer.AutoReset = false;
     lifeTimer.Randomize = false;
     lifeTimer.IsActive  = true;
     lifeTimer.OnIntervalReached.AddListener(Die);
 }
        public override void ComponentAwake()
        {
            intervalTimer = GetRequiredComponent <IntervalTimerComponent>();
            intervalTimer.OnIntervalReached.AddListener(ShootIntervalReached);

            actorBehavior = GetRequiredComponent <ActorBehavior>();

            explosionObject = GetRequiredResource <GameObject>($"{ResourcePaths.PrefabsFolder}/Explosions/GruntExplosion");
            bullet          = GetRequiredResource <GameObject>($"{ResourcePaths.PrefabsFolder}/Projectiles/EnemyBullet");

            base.ComponentAwake();
        }
        public override void ComponentStart()
        {
            if (!UnityUtils.Exists(bulletPrefab))
            {
                Debug.LogWarning($"No bullet prefab specified for {gameObject.name}!");
            }

            if (!Positions.Any())
            {
                Debug.LogError($"Enemy shooter named '{gameObject.name}' doesn't have any predefined positions and his behavior will not work right.");
            }

            var brain = GetRequiredComponent <HumanoidNPCBrainComponent>();

            if (!UnityUtils.Exists(brain))
            {
                throw new UnityException($"Unable to find a HumanoidNPCBrain on {gameObject.name}");
            }

            brain.attackByPlayer.AddListener(OnAttackedByPlayer);
            brain.attackBegin.AddListener(OnAttackBegin);
            brain.attackEnd.AddListener(OnAttackEnd);
            brain.damageEnable.AddListener(OnDamageEnable);
            brain.damageDisable.AddListener(OnDamageDisable);

            var brainTimerPrefabTemp = new GameObject();

            brainTimerPrefabTemp.AddComponent <IntervalTimerComponent>();
            var inst = Instantiate(brainTimerPrefabTemp, transform);

            inst.name = "BrainTimer";

            brainTimer       = GetRequiredComponent <IntervalTimerComponent>(inst);
            brainTimer.Label = "BrainTimerComponent";
            brainTimer.SetInterval((int)UnityEngine.Random.Range(thinkTimeMin, thinkTimeMax));
            brainTimer.SelfDestruct = false;
            brainTimer.Randomize    = false;
            brainTimer.AutoReset    = true;
            brainTimer.OnIntervalReached.AddListener(BrainUpdate);

            shooterAnimator = GetRequiredComponent <ShooterSkeletonAnimatorComponent>();

            if (!UnityUtils.Exists(shooterAnimator))
            {
                throw new UnityException($" {gameObject.name} requires a shooter skeleton animator and you don't have that.");
            }

            Destroy(brainTimerPrefabTemp);

            currentSeekedPosition = FindNearestShooterPosition();

            base.ComponentStart();
        }
        public override void ComponentAwake()
        {
            timer          = GetRequiredComponent <IntervalTimerComponent>();
            timer.IsActive = false;
            fadeAnimator   = GetRequiredComponent <Animator>(fadeObject);

            antagonistAnimator  = GetRequiredComponent <Animator>(antagonistActor);
            protagonistAnimator = GetRequiredComponent <Animator>(protagonistActor);
            femaleAnimator      = GetRequiredComponent <Animator>(femaleActor);

            antagSkeleton  = GetRequiredComponent <SkeletonMecanim>(antagonistActor);
            antagRigidBody = GetRequiredComponent <Rigidbody2D>(antagonistActor);

            // Localize and prepare the dynamic menu
            // Load the dialog menu strings
            stringLoader.Load("Intro/intro_05_protagOptions.xml");

            dynamicMenuComponent = GetRequiredComponent <DynamicMenuComponent>(dynamicMenuObject);
            dynamicMenuObject.SetActive(false);

            var allMenuItems = new DynamicMenuComponent.MenuItem[] {
                new DynamicMenuComponent.MenuItem()
                {
                    Text = stringLoader.Value["protag_scared"], OnItemSelected = new UnityEvent()
                },
                new DynamicMenuComponent.MenuItem()
                {
                    Text = stringLoader.Value["protag_smart"], OnItemSelected = new UnityEvent()
                },
                new DynamicMenuComponent.MenuItem()
                {
                    Text = stringLoader.Value["protag_brave"], OnItemSelected = new UnityEvent()
                },
                new DynamicMenuComponent.MenuItem()
                {
                    Text = stringLoader.Value["protag_silent"], OnItemSelected = new UnityEvent()
                }
            };

            allMenuItems[0].OnItemSelected.AddListener(() => ChooseOption(0));
            allMenuItems[1].OnItemSelected.AddListener(() => ChooseOption(1));
            allMenuItems[2].OnItemSelected.AddListener(() => ChooseOption(2));
            allMenuItems[3].OnItemSelected.AddListener(() => ChooseOption(3));

            dynamicMenuComponent.InitializeMenu(allMenuItems);

            femaleBrainParticleSystem = GetRequiredComponent <ParticleSystem>(GetRequiredChild("BrainChunkEmitter", femaleActor));
            protagBrainParticleSystem = GetRequiredComponent <ParticleSystem>(GetRequiredChild("BrainChunkEmitter", protagonistActor));


            base.ComponentAwake();
        }
Example #11
0
        public override void ComponentAwake()
        {
            if (!UnityUtils.Exists(textMesh))
            {
                throw new UnityException("You didn't drag the text mesh pro object");
            }

            timer          = GetRequiredComponent <IntervalTimerComponent>();
            timer.IsActive = true;

            SetText("hey paulie spaghetti tony burroni");
            base.ComponentAwake();
        }
        private void InitializeTimers()
        {
            shootTimer = gameObject.AddComponent <IntervalTimerComponent>();
            shootTimer.SetInterval(SHOOT_COOLDOWN);
            shootTimer.IsActive  = true;
            shootTimer.AutoReset = false;

            stunTimer = gameObject.AddComponent <IntervalTimerComponent>();
            stunTimer.SetInterval(STUN_COOLDOWN);
            stunTimer.IsActive  = false;
            stunTimer.AutoReset = false;
            stunTimer.OnIntervalReached.AddListener(OnStunTimerIntervalReached);
        }
        public override void ComponentAwake()
        {
            rigidBody = GetRequiredComponent <Rigidbody2D>();

            timer                   = gameObject.AddComponent <IntervalTimerComponent>();
            timer.IsActive          = false;
            timer.AutoReset         = false;
            timer.OnIntervalReached = new UnityEngine.Events.UnityEvent();
            timer.OnIntervalReached.AddListener(GetNextInstruction);
            timer.AutoReset = false;

            index = 0;
            base.ComponentAwake();
        }
        public void PhaseBegin(ILevelContext context)
        {
            GameObject asteroidPrefab = ComponentBase.GetRequiredResource <GameObject>($"{ResourcePaths.PrefabsFolder}/Projectiles/{GameObjects.Projectiles.Asteroid}");

            // Create an asteroid spawner which will generate a random asteroid every half second
            asteroidSpawner = ComponentBase.InstantiateInLevel("AsteroidSpawner", Vector3.zero, typeof(AutoSpawnerComponent));
            ComponentBase.GetRequiredComponent <AutoSpawnerComponent>(asteroidSpawner).Initialize(500, asteroidPrefab);


            // A formation will spawn after a while
            intervalTimerObject = new GameObject("FormationSpawnTimer");

            intervalTimerObject.AddComponent <IntervalTimerComponent>();
            IntervalTimerComponent timer = ComponentBase.GetRequiredComponent <IntervalTimerComponent>(intervalTimerObject);

            timer.SetInterval(15000); // 15 seconds
            timer.OnIntervalReached.AddListener(TimerDone);
            timer.SelfDestruct = true;
            timer.IsActive     = true;
        }
        public override void ComponentStart()
        {
            if (!UnityUtils.Exists(bulletPrefab))
            {
                Debug.LogWarning($"No bullet prefab specified for {gameObject.name}!");
            }


            var brain = GetRequiredComponent <HumanoidNPCBrainComponent>();

            brain.attackBegin.AddListener(OnAttackBegin);
            brain.attackByPlayer.AddListener(OnAttackedByPlayer);

            var brainTimerPrefabTemp = new GameObject();

            brainTimerPrefabTemp.AddComponent <IntervalTimerComponent>();
            var inst = Instantiate(brainTimerPrefabTemp, transform);

            inst.name = "BrainTimer";

            brainTimer       = GetRequiredComponent <IntervalTimerComponent>(inst);
            brainTimer.Label = "BrainTimerComponent";
            brainTimer.SetInterval((int)UnityEngine.Random.Range(thinkTimeMin, thinkTimeMax));
            brainTimer.SelfDestruct = false;
            brainTimer.Randomize    = false;
            brainTimer.AutoReset    = true;
            brainTimer.OnIntervalReached.AddListener(BrainUpdate);

            shooterAnimator = GetRequiredComponent <ShooterSkeletonAnimatorComponent>();

            if (!IsFacingRight)
            {
                shooterAnimator.FaceTowardsPosition(transform.position.x - 1);
            }

            Destroy(brainTimerPrefabTemp);

            base.ComponentStart();
        }