Пример #1
0
    private void Awake()
    {
        current = this;

        activeList   = new List <Projectile>();
        inactiveList = new List <Projectile>();
    }
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            this.manager = new ComponentManager(this.Content);
            colsys       = new CollisionSystem();
            consys       = new ControlSystem();
            projsys      = new ProjectileSystem();
            pathsys      = new PathingSystem();
            anisys       = new AnimatedSpriteSystem();
            paused       = false;
            mainMenu     = true; //start with main menu open
            dead         = false;
            realDead     = false;
            victory      = false;
            //Create stages
            this.stages = new List <Stage>();

            Stage stage1 = new Stage("stage1.tmx", this.manager);

            this.stages.Add(stage1);
            Stage stage2 = new Stage("stage2.tmx", this.manager);

            this.stages.Add(stage2);
            Stage stage3 = new Stage("stage3.tmx", this.manager);

            this.stages.Add(stage3);
            Stage stage4 = new Stage("stage4.tmx", this.manager);

            this.stages.Add(stage4);
            Stage stage5 = new Stage("stage5.tmx", this.manager);

            this.stages.Add(stage5);
            Stage stage6 = new Stage("stage6.tmx", this.manager);

            this.stages.Add(stage6);
            Stage stage7 = new Stage("stage7.tmx", this.manager);

            this.stages.Add(stage7);
            Stage stage8 = new Stage("stage8.tmx", this.manager);

            this.stages.Add(stage8);
            Stage stage9 = new Stage("stage9.tmx", this.manager);

            this.stages.Add(stage9);
            Stage stage10 = new Stage("stage10.tmx", this.manager);

            this.stages.Add(stage10);
            Stage stage11 = new Stage("stage11.tmx", this.manager);

            this.stages.Add(stage11);
            Stage stage12 = new Stage("stage12.tmx", this.manager);

            this.stages.Add(stage12);

            this.manager.numStages = this.stages.ToArray().Length;
            this.screenBox         = new Rectangle(0, 0, 800, 480);

            base.Initialize();
        }
Пример #3
0
 private void TimePunchFireProjectile(FrameArgs e)
 {
     if (e.CurrentFrame == 1)
     {
         ProjectileSystem.Add(new BlueBlastProjectile(_player));
         _timeGunFireSound.Play();
         _player.ComplexAnimation.FrameChanged -= TimePunchFireProjectile;
     }
 }
Пример #4
0
    private void Awake()
    {
        inputSystem      = GetComponent <InputSystem>();
        projectileSystem = GetComponent <ProjectileSystem>();

        // String reference (finding gameobject BubbleSpawner) dangerous because string might be wrong
        bubbleSpawner = GameObject.Find("BubbleSpawner").GetComponent <BubbleSpawner>();
        scoreSystem   = GetComponent <ScoreSystem>();
        audioPlayer   = GetComponent <AudioPlayer>();
    }
Пример #5
0
 // TODO: Use an observer pattern instead of a singleton
 private void Awake()
 {
     if (Instance != null && Instance != this)
     {
         Destroy(this.gameObject);
     }
     else
     {
         Instance = this;
     }
     spawner = new ProjectileSpawner(projectile);
 }
Пример #6
0
 public static void Initialize()
 {
     SpriteSheet.GetData <Color>(SpriteSheetColorData);
     _clouds   = new List <Cloud>();
     Entities  = new List <Entity>();
     TileArray = new Tile[0];
     WallArray = new Tile[0];
     _players.Add(new Player(PlayerIndex.One));
     ProjectileSystem.Initialize();
     ParticleSystem.Initialize();
     scriptManager.Initialize();
     DialogueSystem.Initialize();
     //_players.Add(new Player(PlayerIndex.Two));
 }
Пример #7
0
    //// MonoBehaviour methods
    void Awake()
    {
        Instance = this;

        // Meta
        _gameSetup = Resources.Load("Data/GameSetup") as GameSetup;

        // Map
        _mapObject = GameObject.Find("Map");
        if (_mapObject == null)
        {
            SetupErrorMessage("Map game object not linked");
        }
        else
        {
            _core        = _mapObject.transform.Find("Core").gameObject;
            _spawnPoints = _mapObject.transform.Find("SpawnPoints").gameObject;
        }

        // IO/Input/UI
        _inputControllerReference = GameObject.Find("UICanvas").GetComponent <InputController>();
        if (_inputControllerReference == null)
        {
            SetupErrorMessage("InputController game object not linked");
        }

        // Construction System
        Transform constructionsParent = transform.Find("Constructions");

        _constructionSystem = new ConstructionSystem(constructionsParent);

        // Projectile system
        Transform projectilesParent = transform.Find("Projectiles");

        _projectileSystem = new ProjectileSystem(projectilesParent);

        // Enemy System
        Transform enemiesParent = transform.Find("Enemies");

        _spawn = new SpawnSystem(enemiesParent);

        // Register notification callbacks
        Input.RegisterMouseMovementListener(_constructionSystem.OnMouseChange);
        Input.RegisterMouseClickListener(_constructionSystem.OnMouseClick);
        RegisterInteractionChangedListener(_constructionSystem.OnPlayerInteractionChanged);

        RegisterInteractionChangedListener(_inputControllerReference.OnPlayerInteractionChanged);
    }
Пример #8
0
    private void OnDrawGizmos()
    {
        if (on)
        {
            if (!projectileSystem)
            {
                projectileSystem = GetComponent <ProjectileSystem>();
            }

            if (projectileSystem)
            {
                Gizmos.color = color;

                Gizmos.DrawLine(projectileSystem.ProjectileSpawnPoint.position, projectileSystem.ProjectileSpawnPoint.forward * range);
            }
        }
    }
Пример #9
0
        public static void DrawGlows(SpriteBatch spriteBatch)
        {
            foreach (var tileNumber in ChunkManager.GetVisibleIndexes())
            {
                if (tileNumber >= 0 && tileNumber < TileArray.Length)
                {
                    TileArray[tileNumber]?.DrawGlow(spriteBatch);
                }
            }

            foreach (Entity en in Entities)
            {
                en.DrawGlow(spriteBatch);
            }

            ProjectileSystem.DrawGlow(spriteBatch);
        }
Пример #10
0
    private void Awake()
    {
        instance = this;

        types       = Resources.FindObjectsOfTypeAll <ProjectileType>();
        typeCount   = types.Length;
        projectiles = new SimpleTransform[typeCount][];
        counts      = new int[typeCount];
        hitEffects  = new ComponentPool <ParticleSystem> [typeCount];
        fireEffects = new ComponentPool <ParticleSystem> [typeCount];
        for (int i = 0; i < typeCount; i++)
        {
            projectiles[i] = new SimpleTransform[MAX_PROJECTILES_PER_TYPE];
            counts[i]      = 0;

            hitEffects[i]  = new ComponentPool <ParticleSystem>(10, types[i].blastFx);
            fireEffects[i] = new ComponentPool <ParticleSystem>(10, types[i].fireFx);
        }
    }
Пример #11
0
        public static void Draw(SpriteBatch spriteBatch)
        {
            if (TMBAW_Game.CurrentGameMode == GameMode.Edit)
            {
                LevelEditor.DrawBehindTiles(spriteBatch);
            }

            int[] indexes = ChunkManager.GetVisibleIndexes();
            if (indexes != null)
            {
                foreach (var tileNumber in indexes)
                {
                    if (tileNumber >= 0 && tileNumber < TileArray.Length)
                    {
                        TileArray[tileNumber].Draw(spriteBatch);
                    }
                }
            }

            foreach (Player player in GameWorld.GetPlayers())
            {
                player.Draw(spriteBatch);
            }

            for (var i = 0; i < Entities.Count; i++)
            {
                if (!Entities[i].IsDead)
                {
                    Entities[i].Draw(spriteBatch);
                }
            }

            ProjectileSystem.Draw(spriteBatch);

            //ParticleSystem.DrawNormalParticles(spriteBatch);

            if (TMBAW_Game.CurrentGameMode == GameMode.Edit)
            {
                LevelEditor.Draw(spriteBatch);
            }
        }
Пример #12
0
        public static void DrawLights(SpriteBatch spriteBatch)
        {
            int[] indices = ChunkManager.GetVisibleIndexes();
            if (indices != null)
            {
                foreach (var tileNumber in indices)
                {
                    if (tileNumber >= 0 && tileNumber < TileArray.Length)
                    {
                        TileArray[tileNumber]?.DrawLight(spriteBatch);
                    }
                }
            }

            foreach (Entity en in Entities)
            {
                en.DrawLight(spriteBatch);
            }

            ProjectileSystem.DrawLights(spriteBatch);
        }
Пример #13
0
	public float burstCooldownTime; // When assigning this, take last bullet's reload time into account

	public IEnumerator FireBurst()
	{
		float continueTime = 0f;
		for (int i = 0; i < burstCount; i++)
		{
			for (int ii = 0; ii < muzzles.Length; ii++)
			{
				ProjectileSystem.Shoot(
					muzzles[ii].position,
					muzzles[ii].rotation,
					projectile
				);
			}
			
			continueTime = Time.time + reloadTime;
			while (Time.time < continueTime)
				yield return null;
		}

		continueTime = Time.time + burstCooldownTime;
		while (Time.time < continueTime)
			yield return null;
	}
Пример #14
0
 private void Start()
 {
     projectileSystem = ProjectileSystem.GetInstance();
 }
Пример #15
0
 private void Start()
 {
     m_projectileSystem = ProjectileSystem.GetInstance();
     m_projectileSystem.RegisterProjectile(this);
     gameObject.SetActive(false);
 }
Пример #16
0
        public static void UpdateWorld()
        {
            ParticleSystem.Update();
            //ParticleSystem.Update();
            Weather.Update();

            if (TMBAW_Game.CurrentGameMode == GameMode.Edit)
            {
                foreach (Player player in GetPlayers())
                {
                    player.ComplexAnimation.RemoveAllFromQueue();
                    player.AddAnimationToQueue("editMode");
                }
                LevelEditor.Update();
            }
            else
            {
                if (IsTestingLevel)
                {
                    if (GetPlayers()[0].IsTestLevelPressed())
                    {
                        LevelEditor.GoBackToEditing();
                    }
                }
                UpdateVisual();
            }

            TimesUpdated++;

            ProjectileSystem.Update();

            for (var i = Entities.Count - 1; i >= 0; i--)
            {
                var entity = Entities[i];
                if (entity.ToDelete)
                {
                    entity.Destroy();
                }
            }
            foreach (Player player in GetPlayers())
            {
                player.Update();
            }

            if (TMBAW_Game.CurrentGameMode == GameMode.Play)
            {
                foreach (Player player in GameWorld.GetPlayers())
                {
                    PlayerTrail.Add(player);
                }
            }

            foreach (var c in _clouds)
            {
                c.CheckOutOfRange();
                c.Update();
            }
            for (var i = 0; i < Entities.Count; i++)
            {
                var entity = Entities[i];
                if (entity.IsDead)
                {
                    continue;
                }
                entity.Update();

                //// Check enemy collision with other enemies.
                //for (int j = i + 1; j < Entities.Count; j++)
                //{
                //    if (Entities[i].IsTouchingEntity(Entities[j]))
                //    {
                //        if (Entities[i].Position.X > Entities[j].Position.X)
                //        {
                //            Entities[i].SetX(Entities[j].Position.X + Entities[j].CollRectangle.Width / 2);
                //        }
                //        else
                //        {
                //            Entities[i].SetX(Entities[j].Position.X - Entities[i].CollRectangle.Width / 2);
                //        }
                //        Entities[i].ForceUpdateCollisionRectangle();
                //    }
                //}
            }


            foreach (var tileNumber in ChunkManager.GetVisibleIndexes())
            {
                if (tileNumber >= 0 && tileNumber < TileArray.Length)
                {
                    TileArray[tileNumber]?.Update();
                }
            }

            if (Session.IsHost)
            {
                Session.SendEntityUpdates();
            }
        }