Esempio n. 1
0
        public override void update(float elapsed)
        {
            this.timeAlive += elapsed;
            base.update(elapsed);
            this.dustEmitter.update(elapsed);

            PositionGenerator.getInstance().markPosition(base.Position, false);
            if (this.stage == Stage.Opening)
            {
                if (this.spawnSprite.AnimationManager.State == AnimationState.Paused)
                {
                    this.stage = Stage.Idle;
                    base.init(this.idleImage);
                }
            }
            else if (this.stage == Stage.Closing)
            {
                if (this.spawnSprite.AnimationManager.State == AnimationState.Paused)
                {
                    this.Release = true;
                }
            }
            else
            {
                if (this.timeAlive >= TIME_TO_LIVE)
                {
                    this.stage = Stage.Closing;
                    this.spawnSprite.AnimationManager.State = AnimationState.PlayReversedOnce;
                    this.spawnSprite.reset();
                    base.init(this.spawnSprite);
                    PositionGenerator.getInstance().markPosition(base.Position);
                    SoundManager.getInstance().playSoundEffect(this.sfxEmitter, this.crumpleSFX);
                }
            }
        }
Esempio n. 2
0
        private void init(bool fullRegen = false)
        {
            Vector3 min = new Vector3(0, Constants.HUD_OFFSET, 0f);
            Vector3 max = new Vector3(Constants.RESOLUTION_X, Constants.RESOLUTION_Y, 0f);

            this.boundary = new BoundingBox(min, max);
            this.rand     = new Random();
            PositionGenerator.getInstance().init(this.rand);
            SpawnGenerator.getInstance().SpawnRequests.Clear();
            if (StateManager.getInstance().GameMode == GameMode.OnePlayer)
            {
                this.playerOne = new Snake(this.content, Constants.HEADING_UP, 0f, ConfigurationManager.getInstance().PlayerOnesControls);
            }
            else
            {
                this.playerOne = new Snake(this.content, Constants.HEADING_UP, 100f, ConfigurationManager.getInstance().PlayerOnesControls);
                this.playerTwo = new Snake(this.content, Constants.HEADING_UP, -100f, ConfigurationManager.getInstance().PlayerTwosControls);
            }

            if (fullRegen)
            {
                this.backGround  = new BackGround(this.content);
                this.hud         = new HUD(this.content);
                this.foodManager = new FoodManager(content, this.rand);
                this.portals     = new PortalManager(content, this.rand);
                this.walls       = new WallManager(content, this.rand);
            }

#if DEBUG
            this.debugLine = LoadingUtils.load <Texture2D>(this.content, "Chip");
#endif
        }
Esempio n. 3
0
        public void render(SpriteBatch spriteBatch)
        {
            if (this.backGround != null)
            {
                this.backGround.render(spriteBatch);
            }

            if (this.foodManager != null)
            {
                this.foodManager.render(spriteBatch);
            }
            if (this.portals != null)
            {
                this.portals.render(spriteBatch);
            }
            if (this.playerOne != null)
            {
                this.playerOne.render(spriteBatch);
            }
            if (this.playerTwo != null)
            {
                this.playerTwo.render(spriteBatch);
            }

            if (this.walls != null)
            {
                this.walls.render(spriteBatch);
            }

            if (this.hud != null)
            {
                this.hud.render(spriteBatch);
            }
#if DEBUG
            if (GameDisplay.debugOn)
            {
                DebugUtils.drawBoundingBox(spriteBatch, this.boundary, Constants.DEBUG_BBOX_Color, debugLine);
                Vector2 position;
                for (int y = 0; y <= PositionGenerator.getInstance().Layout.GetUpperBound(0); y++)
                {
                    for (int x = 0; x <= PositionGenerator.getInstance().Layout.GetUpperBound(1); x++)
                    {
                        position = new Vector2(PositionGenerator.GRID_PIECE_SIZE * x, PositionGenerator.GRID_PIECE_SIZE * y);
                        if (PositionGenerator.getInstance().Layout[y, x])
                        {
                            spriteBatch.Draw(this.overlayTexture, position, Color.Gray);
                        }
                        else
                        {
                            spriteBatch.Draw(this.overlayTexture, position, Color.Red);
                        }
                    }
                }
            }
#endif
        }
Esempio n. 4
0
        public virtual void handleCollision(Vector2 heading)
        {
            this.LifeStage = Stage.Dying;
            BaseParticle2DEmitterParams parms = new BaseParticle2DEmitterParams();

            parms.ParticleTexture = this.deathParticleTexture;
            this.deathEmitter     = new DeathParticleEmitter(parms, base.Position, heading, this.dyingCharacterTextures);
            PositionGenerator.getInstance().markPosition(base.Position);
            base.init(null);
        }
Esempio n. 5
0
        public void reset(bool setState = true)
        {
            if (setState)
            {
                StateManager.getInstance().CurrentGameState = StateManager.GameState.Loading;
            }
            StateManager.getInstance().WhosTurn = StateManager.Player.One;
            SFXEngineParams sfxParms            = new SFXEngineParams();

            sfxParms.Muted = false;
            this.sfxEngine = new SFXEngine(sfxParms);
            this.terrain   = new Terrain(Content);
            this.players   = new Launcher[4];
            this.nuke      = new Nuke(Content, this.sfxEngine);

            NukeDelegate          nukeDelegate   = null;
            ClosestTargetDelegate targetDelegate = null;

            loadDeletagtes(out nukeDelegate, out targetDelegate);

            PositionGenerator.getInstance().reset();
            for (int i = 0; i < this.players.Length; i++)
            {
                if (StateManager.getInstance().TypeOfGame == StateManager.GameType.PlayerVsPlayer)
                {
                    this.players[i] = new Player(Content, this.sfxEngine, PositionGenerator.getInstance().generate(), nukeDelegate, i);
                }
                else if (i == 0)
                {
                    this.players[i] = new Player(Content, this.sfxEngine, PositionGenerator.getInstance().generate(), nukeDelegate, i);
                }
                else
                {
                    this.players[i] = new Enemy(Content, this.sfxEngine, PositionGenerator.getInstance().generate(), nukeDelegate,
                                                i, targetDelegate);
                }
            }

            if (StateManager.getInstance().TypeOfGame == StateManager.GameType.PlayerVsComputers)
            {
                // now that all parties are setup, find initial targets
                for (int i = 1; i < this.players.Length; i++)
                {
                    ((Enemy)this.players[i]).findTarget();
                }
            }
            this.explosionEmitter = new ExplosionParticleEmitter(Content, new BaseParticle2DEmitterParams());

            // sfx
            this.explosionSFX = LoadingUtils.load <SoundEffect>(Content, "Explosion");
        }
Esempio n. 6
0
        public Food(ContentManager content, Random rand, int points, float speedMultiplier, List <string> dyingCharacterTextureNames, string deathParticleTextureName,
                    string idleTextureName, string spawnTextureName, string spawnSFXName, string idleSFXName, string dyingSFXName, float spawnPositionYOffset = 0f)
            : base(content)
        {
            this.Points          = points;
            this.SpeedMultiplier = speedMultiplier;
            this.LifeStage       = Stage.Spawn;

            this.dyingCharacterTextures = new List <Texture2D>();
            foreach (string texture in dyingCharacterTextureNames)
            {
                this.dyingCharacterTextures.Add(LoadingUtils.load <Texture2D>(content, texture));
            }
            this.deathParticleTexture = LoadingUtils.load <Texture2D>(content, deathParticleTextureName);

            Animated2DSpriteLoadSingleRowBasedOnTexture parms = new Animated2DSpriteLoadSingleRowBasedOnTexture();
            BaseAnimationManagerParams animationParms         = new BaseAnimationManagerParams();

            animationParms.AnimationState  = AnimationState.PlayForward;
            animationParms.FrameRate       = 100f;
            animationParms.TotalFrameCount = 4;
            parms.Position        = PositionGenerator.getInstance().generateSpawn();
            parms.Texture         = LoadingUtils.load <Texture2D>(content, idleTextureName);
            parms.Scale           = new Vector2(.5f);
            parms.Origin          = new Vector2(Constants.TILE_SIZE);
            parms.AnimationParams = animationParms;
            this.idleSprite       = new Animated2DSprite(parms);

            animationParms.AnimationState = AnimationState.PlayForwardOnce;
            parms.AnimationParams         = animationParms;
            parms.Texture    = LoadingUtils.load <Texture2D>(content, spawnTextureName);
            parms.Scale      = new Vector2(1f);
            parms.Position   = new Vector2(parms.Position.X, parms.Position.Y + spawnPositionYOffset);
            this.spawnSprite = new Animated2DSprite(parms);

            base.init(this.spawnSprite);

            this.spawnSFX = LoadingUtils.load <SoundEffect>(content, spawnSFXName);
            this.idleSFX  = LoadingUtils.load <SoundEffect>(content, idleSFXName);
            this.dyingSFX = LoadingUtils.load <SoundEffect>(content, dyingSFXName);

            SoundEmitterParams sfxEmitterParms = new SoundEmitterParams {
                SFXEngine   = SoundManager.getInstance().SFXEngine,
                EmittRadius = SFX_EMITT_RADIUS,
                Position    = this.spawnSprite.Position
            };

            this.sfxEmitter = new SoundEmitter(sfxEmitterParms);
            SoundManager.getInstance().addEmitter(this.sfxEmitter);
        }
Esempio n. 7
0
        public void PositionGeneratorInBoundPositions()
        {
            const int         mapSize  = 10;
            const int         nbPlayer = 3;
            PositionGenerator p        = new PositionGenerator();

            Position[] pos = p.GenerateRandomPositions(nbPlayer, mapSize);

            foreach (var position in pos)
            {
                Assert.IsTrue(position.X >= 0);
                Assert.IsTrue(position.Y >= 0);
                Assert.IsTrue(position.X < mapSize);
                Assert.IsTrue(position.X < mapSize);
            }
        }
Esempio n. 8
0
        public void PositionGeneratorDiffrentPositions()
        {
            PositionGenerator p = new PositionGenerator();

            Position[] pos = p.GenerateRandomPositions(3, 10);
            for (int i = 0; i < pos.Length; i++)
            {
                for (int j = 0; j < pos.Length; j++)
                {
                    if (i != j)
                    {
                        Assert.IsTrue(pos[i] != pos[j]);
                    }
                }
            }
        }
Esempio n. 9
0
        private void Spawn()
        {
            if (_enemyCount >= MaxCount)
            {
                return;
            }

            var enemy = Instantiate(_enemyPrefab, PositionGenerator.GetRandomPosition(PositionSettings),
                                    GetRandomRotation());

            _enemyCount++;

            EnemySpawned?.Invoke(enemy);

            enemy.GetComponent <AircraftController>().Died += () => _enemyCount--;
        }
Esempio n. 10
0
        public Portal(ContentManager content, Random rand) : base(content)
        {
            this.lifeStage = Stage.Spawn;

            Animated2DSpriteLoadSingleRowBasedOnTexture parms = new Animated2DSpriteLoadSingleRowBasedOnTexture();
            BaseAnimationManagerParams animationParms         = new BaseAnimationManagerParams();

            animationParms.AnimationState  = AnimationState.PlayForward;
            animationParms.FrameRate       = 100f;
            animationParms.TotalFrameCount = 7;
            parms.Position        = PositionGenerator.getInstance().generateSpawn();
            parms.Texture         = LoadingUtils.load <Texture2D>(content, "PortalOpen");
            parms.Origin          = new Vector2(Constants.TILE_SIZE);
            parms.AnimationParams = animationParms;
            this.idleSprite       = new Animated2DSprite(parms);

            animationParms.AnimationState  = AnimationState.PlayForwardOnce;
            animationParms.TotalFrameCount = 6;
            parms.AnimationParams          = animationParms;
            parms.Texture    = LoadingUtils.load <Texture2D>(content, "PortalSpawn");
            parms.Position   = new Vector2(parms.Position.X, parms.Position.Y);
            this.spawnSprite = new Animated2DSprite(parms);

            base.init(this.spawnSprite);

            BaseParticle2DEmitterParams emitterParams = new BaseParticle2DEmitterParams {
                ParticleTexture = LoadingUtils.load <Texture2D>(content, "Lightning"),
                SpawnDelay      = 500f
            };

            this.lightningEmitter = new LightningParticleEmitter(emitterParams, parms.Position);

            this.spawnSFX   = LoadingUtils.load <SoundEffect>(content, SPAWN_SFX_NAME);
            this.idleSFX    = LoadingUtils.load <SoundEffect>(content, IDLE_SFX_NAME);
            this.closingSFX = LoadingUtils.load <SoundEffect>(content, CLOSING_SFX_NAME);

            SoundEmitterParams sfxEmitterParms = new SoundEmitterParams {
                SFXEngine   = SoundManager.getInstance().SFXEngine,
                EmittRadius = SFX_EMITT_RADIUS,
                Position    = this.spawnSprite.Position
            };

            this.sfxEmitter = new SoundEmitter(sfxEmitterParms);
            SoundManager.getInstance().addEmitter(this.sfxEmitter);
            SoundManager.getInstance().playSoundEffect(this.sfxEmitter, this.spawnSFX);
        }
Esempio n. 11
0
        public void updateMovement(float distance)
        {
            Vector2 currentPosition = base.Position;
            Vector2 position        = base.Position;
            float   rotation        = base.Rotation;

            PositionUtils.handleChildMovement(distance, ref this.heading, ref position, ref rotation, ref this.targetPositions);

            base.Position = position;
            base.Rotation = rotation;
            PositionGenerator.getInstance().updateLocation(currentPosition, position);

            if (this.child != null)
            {
                this.child.updateMovement(distance);
            }
        }
Esempio n. 12
0
        public override void update(float elapsed)
        {
            if (this.idleEmitter != null)
            {
                this.idleEmitter.update(elapsed);
            }

            if (this.LifeStage == Stage.Spawn)
            {
                if (this.spawnSprite.AnimationManager.State == AnimationState.Paused)
                {
                    if (!this.lapseTime)
                    {
                        SoundManager.getInstance().playSoundEffect(this.sfxEmitter, this.spawnSFX);
                    }
                    this.elapsedTime += elapsed;
                    this.lapseTime    = true;
                }

                if (this.elapsedTime >= Constants.SHOW_SPAWN_FOR)
                {
                    base.init(this.idleSprite);
                    this.LifeStage   = Stage.Idle;
                    this.lapseTime   = false;
                    this.elapsedTime = 0f;
                    createIdleEmitter();
                }
            }
            else if (this.lifeStage == Stage.Idle)
            {
                PositionGenerator.getInstance().markPosition(base.Position, false);
            }
            else if (this.LifeStage == Stage.Dying)
            {
                this.elapsedTime += elapsed;
                if (this.elapsedTime >= Constants.DEATH_DURATION)
                {
                    this.Release = true;
                }
                if (this.deathEmitter != null)
                {
                    this.deathEmitter.update(elapsed);
                }
            }
            base.update(elapsed);
        }
Esempio n. 13
0
    override protected void onHit(Collider2D other)
    {
        Camera cam = Camera.main;

        PositionGenerator posGen = new PositionGenerator(ScreenManager.freeZoneRadius[0], ScreenManager.freeZoneRadius[1]);
        Vector2           angle  = posGen.randomPosition(ScreenManager.center);

        Debug.Log(angle);

        gameObject.GetComponent <Collider2D>().enabled = false;
        transform.position       = angle;
        other.transform.position = angle;

        gameObject.GetComponent <SpriteRenderer>().sprite = exit;
        other.GetComponent <PlayerMovement>().changeDirection(-angle);

        Swipe.canSwipeAgain();
    }
Esempio n. 14
0
    public void setUpPB(Components c, PlayerInfo p)
    {
        lifes = p.lifes;
        score = 0;

        comp           = c;
        playInfo       = p;
        weaponHandling = GetComponent <WeaponHandling>();

        setUpSprites();

        setUpSounds();

        weaponHandling.buletManager = transform.parent.GetComponent <BulletManager>();
        weaponHandling.buletManager.createBullets(this);

        characterAnimator = GetComponent <Animator>();

        //pičovina, pak to napojím na PLayerInfo a atribut playerNumber uplně smažu
        playerNumber = p.playerNumber;

        mapMinX   = -4.75f;
        mapMinY   = -4.75f;
        mapMaxX   = 8.6f;
        mapMaxY   = 4f;
        mapHeight = Math.Abs(mapMaxY - mapMinY);
        mapWidth  = Math.Abs(mapMaxX - mapMinX);

        directionMapping.Add(up, 3);
        directionMapping.Add(down, 0);
        directionMapping.Add(left, 1);
        directionMapping.Add(right, 2);

        handsRenderer = transform.Find("hands_down").GetComponent <SpriteRenderer>(); //hands_down, protože sem zrovna na prefab přetáhl hands_down a nejde to změnit..normálně
        handsSprites  = Resources.LoadAll <Sprite>("Sprites/Hands");

        weaponHandling.weaponRenderer = transform.Find("weapon").GetComponent <SpriteRenderer>();

        //setup position generator
        posGenerator = GameObject.Find("PositionGenerator").GetComponent <PositionGenerator>();

        gameManager = GameObject.Find("GameManager").GetComponent <GameManager>();
    }
Esempio n. 15
0
        private void updateMovement(float elapsed)
        {
            float distance = (this.currentSpeed / 1000) * elapsed;

            Vector2 currentPosition = base.Position;

            base.Position += PositionUtils.getDelta(this.heading, distance);
            PositionGenerator.getInstance().updateLocation(currentPosition, base.Position, extraSurround: true);
            this.body.updateMovement(distance);
            this.body.update(elapsed);
            this.tail.updateMovement(distance);
            this.tail.update(elapsed);
            for (int i = 0; i < this.corners.Count; i++)
            {
                if (!this.tail.hasPivot(this.corners[i].Position))
                {
                    this.corners.RemoveAt(i);
                    i--;
                }
            }
        }
Esempio n. 16
0
 public override void update(float elapsed)
 {
     this.elapsedTime += elapsed;
     if (this.LifeStage == Stage.Spawn)
     {
         if (this.spawnSprite.AnimationManager.State == AnimationState.Paused)
         {
             this.lifeStage = Stage.Idle;
             this.idleSprite.AnimationManager.State = AnimationState.PlayForward;
             base.init(this.idleSprite);
             SoundManager.getInstance().playSoundEffect(this.sfxEmitter, this.idleSFX, true);
         }
     }
     if (this.lifeStage == Stage.Idle)
     {
         if (this.elapsedTime >= MAX_OPEN_TIME)
         {
             this.lifeStage = Stage.Closing;
             this.spawnSprite.AnimationManager.State = AnimationState.PlayReversedOnce;
             base.init(this.spawnSprite);
             SoundManager.getInstance().playSoundEffect(this.sfxEmitter, this.closingSFX);
             SoundManager.getInstance().SFXEngine.stop(IDLE_SFX_NAME);
         }
     }
     PositionGenerator.getInstance().markPosition(base.Position, false);
     if (this.lifeStage == Stage.Closing)
     {
         this.lightningEmitter.Emitt = false;
         if (this.spawnSprite.AnimationManager.State == AnimationState.Paused)
         {
             this.Release = true;
             PositionGenerator.getInstance().markPosition(base.Position);
             base.init(null);
         }
     }
     this.lightningEmitter.update(elapsed);
     base.update(elapsed);
 }
Esempio n. 17
0
 public ElementGenerator(float minBound, float maxBound)
 {
     this.posGen   = new PositionGenerator(minBound, maxBound);
     this.elements = new List <GameObject>();
 }
 /// <summary>
 /// Determines if this SearchNode's PositionGenerator exists and cannot advance to the next element.
 /// </summary>
 /// <returns>Whether or not this SearchNode is fully expanded.</returns>
 public bool IsFullyExpanded()
 {
     return(PositionGenerator != null && !PositionGenerator.HasNext());
 }
 private void SetNextPoint()
 {
     NextPoint   = PositionGenerator.GetRandomPosition(PositionSettings);
     NextPoint.y = transform.position.y;
 }
Esempio n. 20
0
    public void setUpPB(Components c, PlayerInfo p)
    {
        lifes = p.lifes;
        score = 0;

        comp = c;
        playInfo = p;
        weaponHandling = GetComponent<WeaponHandling>();

        setUpSprites();

        setUpSounds();

        weaponHandling.buletManager = transform.parent.GetComponent<BulletManager>();
        weaponHandling.buletManager.createBullets(this);

        characterAnimator = GetComponent<Animator>();

        //pičovina, pak to napojím na PLayerInfo a atribut playerNumber uplně smažu
        playerNumber = p.playerNumber;

        mapMinX = -4.75f;
        mapMinY = -4.75f;
        mapMaxX = 8.6f;
        mapMaxY = 4f;
        mapHeight = Math.Abs(mapMaxY - mapMinY);
        mapWidth = Math.Abs(mapMaxX - mapMinX);

        directionMapping.Add(up, 3);
        directionMapping.Add(down, 0);
        directionMapping.Add(left, 1);
        directionMapping.Add(right, 2);

        handsRenderer = transform.Find("hands_down").GetComponent<SpriteRenderer>(); //hands_down, protože sem zrovna na prefab přetáhl hands_down a nejde to změnit..normálně
        handsSprites = Resources.LoadAll<Sprite>("Sprites/Hands");

        weaponHandling.weaponRenderer = transform.Find("weapon").GetComponent<SpriteRenderer>();

        //setup position generator
        posGenerator = GameObject.Find("PositionGenerator").GetComponent<PositionGenerator>();

        gameManager = GameObject.Find("GameManager").GetComponent<GameManager>();
    }