Example #1
0
        public override void SpawnMob()
        {
            int num = Globals.random.Next(0, 100 + 1);

            int total = 0;

            Mob tempMob = null;

            for (int i = 0; i < mobChoices.Count; i++)
            {
                total += mobChoices[i].rate;

                if (num < total)
                {
                    Type sType = Type.GetType("top_down_shooter." + mobChoices[i].mobString, true);

                    // Note: The activator classes do not find changes in variable/params... just a helpful reminder when building!
                    tempMob = (Mob)(Activator.CreateInstance(sType, new Vector2(position.X, position.Y), new Vector2(1, 1), ownerId));

                    break;
                }
            }

            if (tempMob != null)
            {
                GameGlobals.PassMob(tempMob);
            }
        }
Example #2
0
        // Ifs allow for diagonal movement, if-else will prevent diagonal movement
        public override void Update(Vector2 OFFSET)
        {
            // Originally pos - 1 (one pixel/spac)
            if (Globals.keyboard.GetPress("A"))
            {
                pos = new Vector2(pos.X - speed, pos.Y);
            }
            if (Globals.keyboard.GetPress("D"))
            {
                pos = new Vector2(pos.X + speed, pos.Y);
            }
            if (Globals.keyboard.GetPress("W"))
            {
                pos = new Vector2(pos.X, pos.Y - speed);
            }
            if (Globals.keyboard.GetPress("S"))
            {
                pos = new Vector2(pos.X, pos.Y + speed);
            }

            rotation = Globals.RotateTowards(pos, new Vector2(Globals.mouse.newMousePos.X, Globals.mouse.newMousePos.Y));

            if (Globals.mouse.LeftClick())
            {
                GameGlobals.PassProjectile(new Fireball(new Vector2(pos.X, pos.Y), this, new Vector2(Globals.mouse.newMousePos.X, Globals.mouse.newMousePos.Y)));
            }
            base.Update(OFFSET);
        }
Example #3
0
        public override void Update(Vector2 OFFSET)
        {
            // a camera would be a better option but also more complicated
            // might consider using monogame extendends camera or using this for now is fine
            bool checkScroll = false;

            // MUST USE IF/ELSE if you want to prevent diagomal movement
            if (Globals.keyboard.GetPress("A"))
            {
                position    = new Vector2(position.X - speed, position.Y);
                checkScroll = true;
            }

            if (Globals.keyboard.GetPress("D"))
            {
                position    = new Vector2(position.X + speed, position.Y);
                checkScroll = true;
            }

            if (Globals.keyboard.GetPress("W"))
            {
                position    = new Vector2(position.X, position.Y - speed);
                checkScroll = true;
            }

            if (Globals.keyboard.GetPress("S"))
            {
                position    = new Vector2(position.X, position.Y + speed);
                checkScroll = true;
            }

            if (Globals.keyboard.GetSinglePress("D1"))
            {
                // temporary placement right above hero -- will update in near future to be more robust
                GameGlobals.PassBuilding(new ArrowTower(new Vector2(position.X, position.Y - 30), new Vector2(1, 1), ownerId));
            }

            if (checkScroll)
            {
                GameGlobals.CheckScroll(position);

                SetAnimationByName("Walk");
            }
            else
            {
                SetAnimationByName("Stand");
            }

            // rotate hero towards the mouse
            rotation = Globals.RotateTowards(position, new Vector2(Globals.mouse.newMousePos.X, Globals.mouse.newMousePos.Y) - OFFSET);

            if (Globals.mouse.LeftClick())
            {
                // creating a new Vector2 ensures are updating a new piece of memory and not the same as our heros
                GameGlobals.PassProjectile(new Fireball(new Vector2(position.X, position.Y), this, new Vector2(Globals.mouse.newMousePos.X, Globals.mouse.newMousePos.Y) - OFFSET));
            }

            base.Update(OFFSET);
        }
Example #4
0
        public override void SpawnMob()
        {
            Mob tempMob = new Spiderling(new Vector2(position.X, position.Y), new Vector2(1, 1), ownerId);

            if (tempMob != null)
            {
                GameGlobals.PassMob(tempMob);

                totalSpawns++;

                if (totalSpawns >= maxSpawns)
                {
                    dead = true;
                }
            }

            GameGlobals.PassMob(tempMob);
        }
Example #5
0
        // optimimzed for processor vs memory
        public virtual void ShootArrow(Player ENEMY)
        {
            float closetDistance = range, currentDistance = 0;
            Unit  closest = null;

            for (int i = 0; i < ENEMY.units.Count; i++)
            {
                currentDistance = Globals.GetDistance(position, ENEMY.units[i].position);

                if (closetDistance > currentDistance)
                {
                    closetDistance = currentDistance;
                    closest        = ENEMY.units[i];
                }
            }

            if (closest != null)
            {
                GameGlobals.PassProjectile(new Arrow(new Vector2(position.X, position.Y), this, new Vector2(closest.position.X, closest.position.Y)));
            }
        }
Example #6
0
 public virtual void SpawnEggSac()
 {
     GameGlobals.PassSpawnPoint(new SpiderEggSac(new Vector2(position.X, position.Y), new Vector2(1, 1), ownerId, null));
 }
Example #7
0
 public virtual void SpawnMob()
 {
     GameGlobals.PassMob(new Imp(new Vector2(position.X, position.Y), new Vector2(1, 1), ownerId));
 }
 public virtual void SpawnMob()
 {
     GameGlobals.PassMob(new Imp(new Vector2(pos.X, pos.Y)));
 }