Esempio n. 1
0
 private void Actor_Spawn(object sender, EventArgs e)
 {
     Actor spawnedActor = (Actor)sender;
     actors.Add(spawnedActor);
     if (spawnedActor.className == "player")
         protagonist = spawnedActor;
 }
        private void Actor_Use(object sender, EventArgs e)
        {
           
            Actor usingActor = (Actor)sender;
            if (usingActor.health > 0)
            {
                int reach = usingActor.reach;
                Vector2 sightVector = usingActor.sightVector;
                Point usePoint = new Point();
                usePoint.X = (int)((usingActor.hitBox.Center.X + (int)(sightVector.X * reach)) / this.curWorld.tileSize);
                usePoint.Y = (int)((usingActor.hitBox.Center.Y + (int)(sightVector.Y * reach)) / this.curWorld.tileSize);
                int[,] tileMap = this.curWorld.getTileMap();
                if (tileMap[usePoint.Y, usePoint.X] == 15)
                {
                    //worldManager.curWorld.useTileAtPoint(usePoint);
                    //Console.Write(worldManager.curLevel);
                    if (this.getWorldChild(0) == null)
                    {
                        playerTransfer = usingActor;
                        this.createNextWorld(0);
                        onWorldChange();
                        playerTransfer = null;

                        //this.spawnActor(protagonist, worldManager.curWorld.getSpawnPos(), 1);
                        //this.spawnActors(worldManager.curWorld.getSpawns());
                    }
                    //isLoadingWorld = false;
                    //Console.Write(worldManager.curLevel);
                }
            }
        }
 private void Actor_Use(object sender, EventArgs e)
 {
    
     Actor usingActor = (Actor)sender;
     if (usingActor.health > 0)
     {
         int reach = usingActor.reach;
         Vector2 sightVector = usingActor.sightVector;
         Point usePoint = new Point();
         usePoint.X = (int)((usingActor.hitBox.Center.X + (int)(sightVector.X * reach)) / this.curWorld.tileSize);
         usePoint.Y = (int)((usingActor.hitBox.Center.Y + (int)(sightVector.Y * reach)) / this.curWorld.tileSize);
         int[,] tileMap = this.curWorld.getTileMap();
         if (tileMap[usePoint.Y, usePoint.X] == 15)
         {
             if (this.getWorldChild(0) == null && !curWorld.isTutorial)
             {
                 playerTransfer = usingActor;
                 this.createNextWorld(0);
                 onWorldChange();
             }
             else if (curWorld.isTutorial)
             {
                 onWorldChange();
             }
         }
     }
 }
Esempio n. 4
0
 public HealthBar(Actor actor, Texture2D barTex):base()
 {
     this.actor = actor;
     bar = new Rectangle(0, 0, barTex.Width, barTex.Height);
     barDimensions = new Rectangle(0, 0, barWidth, barHeight);
     dimensions = new Rectangle(0, 0, barWidth, barHeight);
     barTexture = barTex;
 }
Esempio n. 5
0
 private void Actor_Spawn(object sender, EventArgs e)
 {
     Actor spawnedActor = (Actor)sender;
     actors.Add(spawnedActor);
     if (spawnedActor.className == "player")
     {
         protagonist = spawnedActor;
         //healthBar = new HealthBar(protagonist, healthBarTexture);
     }
 }
Esempio n. 6
0
        public void calcWeaponPos(Actor owner)
        {
            Vector2 gripVector = new Vector2(owner.gripPoint.X - owner.body.Width / 2,
                                        -((owner.body.Height - owner.gripPoint.Y) - owner.body.Height / 2));
            Point rotatedGrip = new Point();
            rotatedGrip.X = (int)(gripVector.X * Math.Cos(owner.bodyRotation)) - (int)(gripVector.Y * Math.Sin(owner.bodyRotation));
            rotatedGrip.Y = (int)(gripVector.X * Math.Sin(owner.bodyRotation)) + (int)(gripVector.Y * Math.Cos(owner.bodyRotation));

            owner.activeWeapon.dimensions.X = owner.body.Center.X + rotatedGrip.X;
            owner.activeWeapon.dimensions.Y = owner.body.Center.Y + rotatedGrip.Y;
            owner.activeWeapon.rotation = owner.bodyRotation + owner.activeWeapon.frameRotation;
        }
Esempio n. 7
0
 private void Actor_Spawn(object sender, EventArgs e)
 {
     Actor spawnedActor = (Actor)sender;
     actors.Add(spawnedActor);
     if (spawnedActor.className == "player")
     {
         protagonist = spawnedActor;
     }
     if (!healthBars.ContainsKey(spawnedActor) && spawnedActor.health < spawnedActor.maxHealth)
     {
         if (spawnedActor.className == "player")
             healthBars[spawnedActor] = new HealthBar(spawnedActor, guiTextures["healthBar"]);
         else
             healthBars[spawnedActor] = new HealthBar(spawnedActor, guiTextures["enemyHealthBar"]);
     }
 }
 public DamageInfo(Actor a, int d, List<Rectangle> aR)
 {
     attacker = a;
     damage = d;
     attackRects = aR;
 }
Esempio n. 9
0
 public void MainGameExited(Object sender, EventArgs eventArgs){
     if(gameUpdateStack.Count > 1)
     {
         paused = false;
         player = null;
         cam.tutorialGui.Clear();
         SoundManager.Instance.stopAllSounds();
         cam.enterStartMenu();
         cam.drawSpace.X = 0;
         cam.drawSpace.Y = 0;
         gameUpdateStack.Pop();
         gameDrawStack.Pop();
         gameUpdate = gameUpdateStack.Peek();
         gameDraw = gameDrawStack.Peek();
         SoundManager.Instance.stopSong("creditsTheme");
     }
     
 }
Esempio n. 10
0
 public Object Clone()
 {
     Actor actorCopy = new Actor(texture, hitBox.Width, hitBox.Height, body.Width, body.Height);
     actorCopy.animations = animations;
     actorCopy.className = className;
     actorCopy.color = new Color(color.ToVector3());
     actorCopy.health = health;
     actorCopy.sight = sight;
     actorCopy.sightVector = new Vector2(sightVector.X, sightVector.Y) ;
     actorCopy.reach = reach;
     return actorCopy;
 }
Esempio n. 11
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            floorTiles = Content.Load<Texture2D>("TempleFloor.png");
            //playerTexture = Content.Load<Texture2D>("protagonistBodyAnimations");
            playerTexture = Content.Load<Texture2D>("dreamManAnimations.png");
            debugSquare = Content.Load<Texture2D>("debugSquare");
            arielBlackFont = Content.Load<SpriteFont>("SpriteFont1");

            device = graphics.GraphicsDevice;
            spriteBatch = new SpriteBatch(GraphicsDevice);
            origin.X = graphics.PreferredBackBufferWidth / 2;
            origin.Y = graphics.PreferredBackBufferHeight / 2;

            random = new Random();

            //actors = new List<Actor>();
            worldManager = new WorldManager(random);
            worldManager.initWorldConfig(Content, "content/Worlds.xml");
            worldManager.initStartingWorld();
            actorManager = new ActorManager(worldManager, random);
            actorManager.initActorConfig(Content, "content/Actors.xml");
            aiController = new AIController();


            //spawnTile = worldManager.curWorld.getSpawnTile();
            tileRect = new Rectangle(0,0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);

            cam = new Camera(spriteBatch, tileRect, worldManager, debugSquare);
            player = new Actor(playerTexture, 25, 25, 64, 64);
            player.isPlayer = true;
            //Point spawnPosition = new Point(spawnTile.X * tileSize + tileSize / 2, spawnTile.Y * tileSize + tileSize / 2);
            actorManager.spawnActor(player, worldManager.curWorld.getSpawnPos(), 1);
            actorManager.spawnActors(worldManager.curWorld.getSpawns());
        }
Esempio n. 12
0
 private void Actor_Spawn(object sender, EventArgs eventArgs)
 {
     Actor actor = (Actor)sender;
     if (actor.className == "player")
         player = actor;
 }
Esempio n. 13
0
        private void WorldManager_worldChange(Object sender, EventArgs eventArgs)
        {
            WorldManager worldManager = (WorldManager)sender;
            if (worldManager.curWorld != null && worldManager.curWorld.isTutorial && gameUpdateStack.Count > 1)
            {
                player = null;
                SoundManager.Instance.stopAllSounds();

                cam.enterStartMenu();
                cam.drawSpace.X = 0;
                cam.drawSpace.Y = 0;
                worldManager.restart();
                gameUpdateStack.Pop();
                gameDrawStack.Pop();
                gameUpdate = gameUpdateStack.Peek();
                gameDraw = gameDrawStack.Peek();
            }
        }
Esempio n. 14
0
        private void Actor_Use(Object sender, EventArgs eventArgs)
        {
            Actor deadActor = (Actor)sender;
            if (deadActor.className == "player" && deadActor.health <= 0 && gameUpdateStack.Count > 1)
            {
                player = null;
                SoundManager.Instance.stopAllSounds();

                cam.enterStartMenu();
                cam.drawSpace.X = 0;
                cam.drawSpace.Y = 0;
                worldManager.restart();
                gameUpdateStack.Pop();
                gameDrawStack.Pop();
                gameUpdate = gameUpdateStack.Peek();
                gameDraw = gameDrawStack.Peek();
            }
        }
Esempio n. 15
0
 public DamageInfo(Actor a, int d, Rectangle aR)
 {
     attacker = a;
     damage = d;
     attackRect = aR;
 }
Esempio n. 16
0
        public bool isInSight(Actor actor, Point point)
        {
            double distance = Math.Sqrt(Math.Pow(point.X - actor.hitBox.Center.X, 2) + Math.Pow(point.Y - actor.hitBox.Center.Y, 2));
            if (distance < actor.sight)
            {
                Vector2 direction = new Vector2(point.X - actor.hitBox.Center.X, point.Y - actor.hitBox.Center.Y);
                direction.Normalize();

                double dotProduct = Vector2.Dot(direction, actor.sightVector);
                if (dotProduct > 0)
                {
                    TraceInfo traceInfo = this.traceWorld(point, actor.hitBox.Center);
                    if (!traceInfo.hitWorld)
                    {
                        return true;
                    }
                }
            }
            return false;
        }
Esempio n. 17
0
 public Object Clone()
 {
     Actor actorCopy = new Actor(texture, hitBox.Width, hitBox.Height, body.Width, body.Height);
     actorCopy.animations = animations;
     actorCopy.lootTable = lootTable;
     actorCopy.className = className;
     actorCopy.color = new Color(color.ToVector3());
     actorCopy.damageFactor = damageFactor;
     actorCopy.gripPoint = new Point(gripPoint.X, gripPoint.Y);
     actorCopy.maxHealth = maxHealth;
     actorCopy.health = health;
     actorCopy.maxSpeed = maxSpeed;
     actorCopy.sight = sight;
     actorCopy.sightVector = new Vector2(sightVector.X, sightVector.Y);
     actorCopy.reach = reach;
     actorCopy.activeWeapon = activeWeapon;
     actorCopy.weapons = (Weapon[])weapons.Clone();
     actorCopy.activeWeaponIndex = activeWeaponIndex;
     return actorCopy;
 }
Esempio n. 18
0
 public void update(Camera cam, Actor Actor)
 {
     if (drawSpace.Center.X != Actor.hitBox.Center.X || drawSpace.Center.Y != Actor.hitBox.Center.Y)
         setFocus(Actor.hitBox.Center.X, Actor.hitBox.Center.Y);
 }
Esempio n. 19
0
 public ActionList(Actor o)
 {
     actions = new List<Action>();
     owner = o;
 }