示例#1
0
 public void attack(NPC checker, Player entity)
 {
     //check to see if NPC attacks Player
     if (checker.withinRange)
     {
         confirmedHit(checker, entity);
     }
 }
示例#2
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            player = new Player(new Vector2(400, 300), "Player1");
            ListHolder.Instance.NPCList = new List<NPC>();
            ListHolder.Instance.WallList = new List<Wall>();
            ListHolder.Instance.setGame(this);
            ListHolder.Instance.player = player;

            //initialize map npc spawns
            MakeNPCList(levelOneLayout);
            pathfinding = new Pathfinding(level1);
            ListHolder.Instance.setPathFinder(pathfinding);
            //path = pathfinding.FindPath(startPoint, endPoint);
            //newPath = pathfinding.FindPath(TSP, TEP);

            Vector2 start = new Vector2(startPoint.X*50, startPoint.Y*50);
            Vector2 end = new Vector2(endPoint.X * 50, endPoint.Y * 50);
            npcMover = new NPC(start, "NPC");

               // pathEndPoint = new GameObject(Content.Load<Texture2D>("endPoint"),end);

            base.Initialize();
        }
示例#3
0
 public void addNPC(NPC NPCToAdd)
 {
     NPCList.Add(NPCToAdd);
 }
示例#4
0
 public Boolean inSweetSpot(NPC target)
 {
     return false;
 }
示例#5
0
        //wall sensor
        public bool WeaponSensor(Player owner, NPC npc, int weaponRange)
        {
            List<NPC> npcInFront = new List<NPC>();
            float[] npcSense = new float[3];

            //If face down

            setNPCDefaults(owner, npc, weaponRange);
            Vector2 distance = new Vector2();

            //straight down
            if (Intersects(main, sightRangeCenter, npcLeft, npcRight, out distance))
            {
                owner.npcSensors[1] = Vector2.Distance(main, distance);
                return true;
            }
            else
            {
                owner.npcSensors[0] = 0;
            }

            //left 45 degrees
            if (Intersects(npcLeft45, sightRangeLeft, npcLeft, npcRight, out distance))
            {
                owner.npcSensors[0] = Vector2.Distance(main, distanceLeft);
                return true;
            }
            else
            {
                owner.npcSensors[0] = 0;
            }

            //right 45 degrees
            if (Intersects(npcRight45, sightRangeRight, npcLeft, npcRight, out distance))
            {
                owner.npcSensors[2] = Vector2.Distance(main, distanceRight);
                return true;
            }
            else
            {
                owner.npcSensors[2] = 0;
            }
            owner.npcList = npcInFront;

            return false;
        }
示例#6
0
        public void setNPCDefaults(Player owner, NPC npc, int weaponRange)
        {
            if (owner.faceDirection <= 235 && owner.faceDirection >= 135)
            {
                main = new Vector2(owner.rectangle.Center.X, owner.rectangle.Bottom); // reference point 1
                npcLeft = new Vector2(npc.rectangle.Left, npc.rectangle.Top);
                npcRight = new Vector2(npc.rectangle.Right, npc.rectangle.Top);
                npcCenter = new Vector2(main.X, npc.rectangle.Top);
                dTmp = Vector2.Distance(main, npcCenter);
                npcLeft45 = new Vector2((float)(main.X - dTmp * Math.Tan(45)), main.Y);
                npcRight45 = new Vector2((float)(main.X + dTmp * Math.Tan(45)), main.Y);
                sightRangeCenter = new Vector2(main.X, (main.Y + weaponRange));
                sightRangeLeft = new Vector2(npcLeft45.X, sightRangeCenter.Y);
                sightRangeRight = new Vector2(npcRight45.X, sightRangeCenter.Y);
                distanceLeft = new Vector2(npcLeft45.X, npc.rectangle.Top);
                distanceRight = new Vector2(npcRight45.X, npc.rectangle.Top);
            }
            else if (owner.faceDirection <= 270 && owner.faceDirection <= 45)
            {
                main = new Vector2(owner.rectangle.Center.X, owner.rectangle.Top); // reference point 1
                npcLeft = new Vector2(npc.rectangle.Left, npc.rectangle.Bottom);
                npcRight = new Vector2(npc.rectangle.Right, npc.rectangle.Bottom);
                npcCenter = new Vector2(main.X, npc.rectangle.Bottom);
                dTmp = Vector2.Distance(main, npcCenter);
                npcLeft45 = new Vector2((float)(main.X - dTmp * Math.Tan(45)), main.Y);
                npcRight45 = new Vector2((float)(main.X + dTmp * Math.Tan(45)), main.Y);
                sightRangeCenter = new Vector2(main.X, (main.Y - weaponRange));
                sightRangeLeft = new Vector2(npcLeft45.X, sightRangeCenter.Y);
                sightRangeRight = new Vector2(npcRight45.X, sightRangeCenter.Y);
                distanceLeft = new Vector2(npcLeft45.X, npc.rectangle.Bottom);
                distanceRight = new Vector2(npcRight45.X, npc.rectangle.Bottom);
            }
            else if (owner.faceDirection <= 315 && owner.faceDirection >= 225)
            {
                main = new Vector2(owner.rectangle.Left, owner.rectangle.Center.Y); // reference point 1
                npcLeft = new Vector2(npc.rectangle.Right, npc.rectangle.Top);
                npcRight = new Vector2(npc.rectangle.Right, npc.rectangle.Bottom);
                sightRangeCenter = new Vector2(main.X - weaponRange, main.Y);
                npcCenter = new Vector2(npc.rectangle.Right, main.Y);
                dTmp = Vector2.Distance(main, npcCenter);
                npcLeft45 = new Vector2(main.X, (float)(main.Y - dTmp * Math.Tan(45)));
                npcRight45 = new Vector2(main.X, (float)(main.Y + dTmp * Math.Tan(45)));
                sightRangeCenter = new Vector2(main.X - weaponRange, main.Y);
                sightRangeLeft = new Vector2(sightRangeCenter.X, npcLeft45.Y);
                sightRangeRight = new Vector2(sightRangeCenter.X, npcRight45.Y);
                distanceLeft = new Vector2(npc.rectangle.Right, npcLeft45.Y);
                distanceRight = new Vector2(npc.rectangle.Right, npcRight45.Y);
            }
            else if (owner.faceDirection >= 45 && owner.faceDirection <= 135)
            {
                main = new Vector2(owner.rectangle.Right, owner.rectangle.Center.Y); // reference point 1
                npcLeft = new Vector2(npc.rectangle.Left, npc.rectangle.Top);
                npcRight = new Vector2(npc.rectangle.Left, npc.rectangle.Bottom);
                sightRangeCenter = new Vector2(main.X + weaponRange, main.Y);
                npcCenter = new Vector2(npc.rectangle.Left, main.Y);
                dTmp = Vector2.Distance(main, npcCenter);
                npcLeft45 = new Vector2(main.X, (float)(main.Y - dTmp * Math.Tan(45)));
                npcRight45 = new Vector2(main.X, (float)(main.Y + dTmp * Math.Tan(45)));
                sightRangeCenter = new Vector2(main.X + weaponRange, main.Y);
                sightRangeLeft = new Vector2(sightRangeCenter.X, npcLeft45.Y);
                sightRangeRight = new Vector2(sightRangeCenter.X, npcRight45.Y);
                distanceLeft = new Vector2(npc.rectangle.Left, npcLeft45.Y);
                distanceRight = new Vector2(npc.rectangle.Left, npcRight45.Y);

            }
        }