示例#1
0
        public void Run(renderable r)
        {
            if (isFired)
            {
                float[] move = lerp(end.X, start.X, end.Y, start.Y);

                bullet.setPos((int)move[0], (int)move[1]);

                if (step > 3)
                {
                    step          = 0;
                    bullet.active = false;
                    isFired       = false;
                }
            }
        }
示例#2
0
        public void spawn(int arrayPos, renderable r)
        {
            //if activeEnemies list is null initialize the list
            if (activeEnemies == null)
            {
                activeEnemies = new List <int>();
            }

            //
            if (!activeEnemies.Contains(arrayPos))
            {
                activeEnemies.Add(arrayPos);
            }

            r.setPos(getRandomPos());
            r.active = true;
        }
示例#3
0
        public override void Run(renderable r)
        {
            if (r.active)
            {
                int xMove = 0;
                int yMove = 0;

                bool moved     = false;
                bool sprinting = false;

                if (Game.input.KeyHeld(Key.W))
                {
                    yMove -= speed;
                    moved  = true;
                }
                if (Game.input.KeyHeld(Key.S))
                {
                    yMove += speed;
                    moved  = true;
                }
                if (Game.input.KeyHeld(Key.A))
                {
                    xMove -= speed;
                    moved  = true;
                }
                if (Game.input.KeyHeld(Key.D))
                {
                    xMove += speed;
                    moved  = true;
                }
                if (Game.input.KeyHeld(Key.LShift))
                {
                    sprinting = true;
                }

                if (moved)
                {
                    if (sprinting)
                    {
                        xMove = (int)(xMove * sprintMultiplyer);
                        yMove = (int)(yMove * sprintMultiplyer);
                    }

                    Point p = CollisionManager.WillItCollide(collider, xMove, yMove);

                    p.X += (int)r.pos.xPos;
                    p.Y += (int)r.pos.yPos;

                    int worldMoveX = 0;
                    int worldMoveY = 0;

                    if (p.X >= wMan.worldMaxX)
                    {
                        p.X = 100;
                        worldMoveX++;
                    }
                    if (p.X <= 0)
                    {
                        p.X = wMan.worldMaxX - 100;
                        worldMoveX--;
                    }

                    if (p.Y >= wMan.worldMaxY)
                    {
                        p.Y = 100;
                        worldMoveY++;
                    }
                    if (p.Y <= 0)
                    {
                        p.Y = wMan.worldMaxY - 100;
                        worldMoveY--;
                    }

                    r.setPos(p);

                    wMan.ChangeCurrentChunk(worldMoveX, worldMoveY);
                }
            }
        }