コード例 #1
0
        public virtual void AI(Nave NAVE)
        {
            pos += Globals.RadialMovement(NAVE.pos, pos, speed); //funcion para que las naves vayan hacia a l nave
            rot  = Globals.RotateTowards(pos, NAVE.pos);

            if (Globals.GetDistance(pos, NAVE.pos) < 15)
            {
                NAVE.GetHit(1);
                dead = true;
            }
        }
コード例 #2
0
        public Projectile2d(string PATH, Vector2 POS, Vector2 DIMS, Unit OWNER, Vector2 TARGET)
            : base(PATH, POS, DIMS) //Clase para tomar la inicializacion de basic2d
        {
            done  = false;
            speed = 5.0f; //rapidez
            owner = OWNER;

            direction = TARGET - owner.pos;
            direction.Normalize();
            rot   = Globals.RotateTowards(pos, new Vector2(TARGET.X, TARGET.Y)); //rotar los proyectiles hacia la nave
            timer = new McTimer(1200);
        }
コード例 #3
0
        public override void Update(Vector2 OFFSET)
        {
            if (Globals.keyboard.GetPress("A")) //Configuración de movimientos
            {
                if (pos.X > 32)                 //margen izquierdo
                {
                    pos = new Vector2(pos.X - speed, pos.Y);
                }
            }
            if (Globals.keyboard.GetPress("D"))
            {
                if (pos.X < 778)  //margen derecho
                {
                    pos = new Vector2(pos.X + speed, pos.Y);
                }
            }
            if (Globals.keyboard.GetPress("W"))
            {
                if (pos.Y > 25)  //margen superior
                {
                    pos = new Vector2(pos.X, pos.Y - speed);
                }
            }
            if (Globals.keyboard.GetPress("S"))
            {
                if (pos.Y < 420)  //margen inferior
                {
                    pos = new Vector2(pos.X, pos.Y + speed);
                }
            }
            Console.Write(pos + "\n");                                                                               //imprimir posicion de nave
            rot = Globals.RotateTowards(pos, new Vector2(Globals.mouse.newMousePos.X, Globals.mouse.newMousePos.Y)); //rotacion de nave segun la posicion del mouse

            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)));  //activar proyectil, se pasa por delegade
            }
            base.Update(OFFSET);
        }