Example #1
0
        public Bullet(ContentManager Content, GraphicsDevice graphicsDevice)
        {
            active = false;
            fromPlayer = false;
            position = Vector3.Zero;
            direction = Vector3.Zero;
            speed = 0;
            distance = 0;
            maxDist = 0;
            strength = 1;
            type = 0;
            mirror = false;
            waveTime = new TimeSpan(0);
            element = Constants.ELM_NIL;
            bulletOb = new ModelObject(Content.Load<Model>("cube_rounded"));

            Texture2D texture = Content.Load<Texture2D>("Particles/fire");

            particleEffect = new ParticleEffect(10000, graphicsDevice, texture, Color.Gold, Color.Crimson, 0.2f);
            particleEffect.VelocityScaling = 8.0f;
            gd = graphicsDevice;
        }
Example #2
0
        public World(ContentManager Content, GraphicsDevice gdev)
        {
            device = gdev;
            content = Content;
            SIZE = Constants.MAP_SIZE;
            mapData = new char[SIZE][];
            mapObjects = new ModelObject[SIZE][];
            moveData = new byte[SIZE][];
            ground = new ModelObject[SIZE][];
            player_start = new int[2];
            skybox = new Skybox(gdev, Content, 2);

            maps = new List<Map>(1);
            scanFiles();

            spawners = new NPCSpawner[4];

            for (int i = 0; i < 4; ++i)
            {
                spawners[i] = new NPCSpawner();
            }

            spawner_count = 0;

            for (int i = 0; i < SIZE; ++i)
            {
                mapData[i] = new char[SIZE];
                moveData[i] = new byte[SIZE];
                mapObjects[i] = new ModelObject[SIZE];
                ground[i] = new ModelObject[SIZE];
            }

            groundObs   = new Model[4];
            ground2Obs  = new Model[4];
            ground3Obs  = new Model[4];
            wallObs     = new Model[4];
            wall2Obs    = new Model[4];

            #region Objects theme 0
            groundObs[0] = content.Load<Model>("Models\\floor_sim");
            ground2Obs[0] = content.Load<Model>("Models\\floor_sim");
            ground3Obs[0] = content.Load<Model>("Models\\floor_sim");
            wallObs[0] = content.Load<Model>("Models\\wall_sim");
            wall2Obs[0] = content.Load <Model>("Models\\mainframe");
            #endregion

            #region Objects theme 1
            groundObs[1] = content.Load<Model>("Models\\grass");
            ground2Obs[1] = content.Load<Model>("Models\\grass2");
            ground3Obs[1] = content.Load<Model>("Models\\grass3");
            wallObs[1] = content.Load<Model>("Models\\stone");
            wall2Obs[1] = content.Load<Model>("Models\\tree1");
            #endregion

            #region Objects theme 2
            groundObs[2] = content.Load<Model>("Models\\wasted");
            ground2Obs[2] = content.Load<Model>("Models\\wasted2");
            ground3Obs[2] = content.Load<Model>("Models\\wasted3");
            wallObs[2] = content.Load<Model>("Models\\rock_w");
            wall2Obs[2] = content.Load<Model>("Models\\cactus");
            #endregion

            #region Objects theme 3
            groundObs[3] = content.Load<Model>("Models\\arctical");
            ground2Obs[3] = content.Load<Model>("Models\\arctical2");
            ground3Obs[3] = content.Load<Model>("Models\\arctical3");
            wallObs[3] = content.Load<Model>("Models\\stone");
            wall2Obs[3] = content.Load<Model>("Models\\stalagmit");
            #endregion

            _mapID = 0;
            _theme = 0;
            warp(_mapID, _theme);
        }
Example #3
0
 /// <summary>
 /// generates the ground plane: sets ground[i][j] as new ModelObject(groundOb) with according coordinates
 /// </summary>
 private void generateGround(int th)
 {
     for (int i = 0; i < SIZE; i++)
     {
         for (int j = 0; j < SIZE; j++)
         {
             switch (mapData[i][j])
             {
                 case '0':
                     ground[i][j] = new ModelObject(groundObs[th]); break;
                 case '-':
                     ground[i][j] = null; break;
                 case 'o':
                     ground[i][j] = new ModelObject(ground2Obs[th]); break;
                 case 'q':
                     ground[i][j] = new ModelObject(ground3Obs[th]); break;
                 default:
                     ground[i][j] = new ModelObject(groundObs[th]); break;
             }
             if (ground[i][j] == null) continue;
             ground[i][j].Position = new Vector3(i * -2.0f + SIZE - 1, -0.5f, -2.0f * j + SIZE - 1);
             ground[i][j].Scaling = new Vector3(2.0f, 1, 2.0f);
         }
     }
 }
Example #4
0
        /// <summary>
        /// calls generateGround to set the ground ModelObjects
        /// <para></para>
        /// sets moveData and mapObjects according to mapData
        /// <para> </para>
        /// sets up player and npc spawner start positions and activates npc spawners
        /// </summary>
        public void setup(byte th)
        {
            _theme = th;
            generateGround(th);
            spawner_count = 0;
            foreach (NPCSpawner spawner in spawners)
                spawner.active = false;
            Random ran = new Random();

            for (int i = 0; i < Constants.MAP_SIZE; ++i)
            {
                for (int j = 0; j < Constants.MAP_SIZE; ++j)
                {
                    switch (mapData[i][j])
                    {
                        #region tile cases
                        case '0':
                            mapObjects[i][j] = null;
                            moveData[i][j] = 0; break;
                        case 'o':
                            mapObjects[i][j] = null;
                            moveData[i][j] = 0; break;
                        case 'q':
                            mapObjects[i][j] = null;
                            moveData[i][j] = 0; break;
                        case '1':
                            mapObjects[i][j] = new ModelObject(wallObs[th]);
                            mapObjects[i][j].Scaling = new Vector3(2.0f, 1.5f, 2.0f);
                            mapObjects[i][j].Position = new Vector3(i * -2.0f + Constants.MAP_SIZE - 1, 0.25f, -2.0f * j + Constants.MAP_SIZE - 1);
                            moveData[i][j] = 1;
                            break;
                        case '#':
                            mapObjects[i][j] = new ModelObject(wall2Obs[th]);
                            mapObjects[i][j].Scaling = new Vector3(2.0f, 1.5f, 2.0f);
                            mapObjects[i][j].Position = new Vector3(i * -2.0f + Constants.MAP_SIZE - 1, 0.25f, -2.0f * j + Constants.MAP_SIZE - 1);
                            if (th != 0)
                                mapObjects[i][j].Rotation = new Vector3(0, (float)(ran.NextDouble() * Math.PI), 0);
                            moveData[i][j] = 1;
                            break;
                        case '-':
                            mapObjects[i][j] = null;
                            moveData[i][j] = 1;
                            break;
                        case '.':
                            mapObjects[i][j] = null;
                            moveData[i][j] = 2;
                            break;
                        case 'x':
                            player_start[0] = i;
                            player_start[1] = j;
                            mapObjects[i][j] = null;
                            moveData[i][j] = 0;
                            break;
                        case 'A':
                            spawners[0].setPos(i, j);
                            spawner_count++;
                            mapObjects[i][j] = null;
                            moveData[i][j] = 0;
                            break;
                        case 'B':
                            spawners[1].setPos(i, j);
                            spawner_count++;
                            mapObjects[i][j] = null;
                            moveData[i][j] = 0;
                            break;
                        case 'C':
                            spawners[2].setPos(i, j);
                            spawner_count++;
                            mapObjects[i][j] = null;
                            moveData[i][j] = 0;
                            break;
                        case 'D':
                            spawners[3].setPos(i, j);
                            spawner_count++;
                            mapObjects[i][j] = null;
                            moveData[i][j] = 0;
                            break;
                        #endregion
                    }
                }
            }
        }
Example #5
0
        /// <summary>
        /// assigns NPC attributes and ModelObject and activates the NPC
        /// </summary>
        /// <param name="k">NPC kind/species</param>
        /// <param name="m">ModelObject</param>
        /// <param name="p">starting position</param>
        /// <param name="d">starting direction</param>
        /// <param name="l">level</param>
        /// <param name="pl">Player</param>
        /// <param name="npcs">parent NPCCollection (should always be "this")</param>
        public void setup(byte k, ModelObject m, Vector3 p, Vector3 d, int l, Player pl, NPCCollection npcs, byte elem = Constants.ELM_NIL)
        {
            kind      = k;
            model     = m;
            position  = p;
            direction = d;
            level     = l;

            if (kind == Constants.NPC_BOSS)
            {
                level = Math.Min(60, Math.Max(1, level));
            }
            else
            {
                level = Math.Min(50, Math.Max(1, level));
            }

            playerDistance = (pl.Position - this.Position).Length();

            #region kind specific stats
            switch (kind)
            {
            case Constants.NPC_NONE:
                speed         = 0.03f;
                maxHealth     = (int)(50 * Math.Pow(1.05f, level - 1));
                XP            = 2;
                maxCooldn     = 70;
                model.Scaling = new Vector3(0.75f, 0.75f, 0.75f);
                element       = Constants.ELM_NIL;
                strength      = (byte)(10 * Math.Pow(1.045f, level - 1));
                break;

            case Constants.NPC_PLAS:
                speed         = 0.035f;
                maxHealth     = (int)(50 * Math.Pow(1.045f, level - 1));
                XP            = 3;
                maxCooldn     = 80;
                model.Scaling = new Vector3(0.75f, 0.75f, 0.75f);
                element       = Constants.ELM_PLA;
                strength      = (byte)(10 * Math.Pow(1.05f, level - 1));
                break;

            case Constants.NPC_HEAT:
                speed         = 0.04f;
                maxHealth     = (int)(50 * Math.Pow(1.04f, level - 1));
                XP            = 3;
                maxCooldn     = 75;
                model.Scaling = new Vector3(0.5f, 0.5f, 0.5f);
                element       = Constants.ELM_HEA;
                strength      = (byte)(10 * Math.Pow(1.055f, level - 1));
                break;

            case Constants.NPC_ICE:
                speed         = 0.03f;
                maxHealth     = (int)(50 * Math.Pow(1.055f, level - 1));
                XP            = 3;
                maxCooldn     = 90;
                model.Scaling = new Vector3(0.75f, 0.75f, 0.75f);
                element       = Constants.ELM_ICE;
                strength      = (byte)(10 * Math.Pow(1.04f, level - 1));
                break;

            case Constants.NPC_BOSS:
                speed         = 0.02f;
                maxHealth     = (int)(200 * Math.Pow(1.07f, level - 1));
                XP            = 70;
                maxCooldn     = 50;
                model.Scaling = new Vector3(0.75f, 0.75f, 0.75f);
                element       = elem;
                strength      = (byte)Math.Min((10 * Math.Pow(1.06f, level - 1)), 255);
                break;

            default:
                speed     = 0.001f;
                maxHealth = 1;
                XP        = 0;
                maxCooldn = 1000;
                break;
            }
            #endregion

            health         = maxHealth;
            active         = true;
            model.Position = this.position;
            moving         = false;
            newTarget      = false;
            isHit          = false;
            hitTimer       = 0;
            isDead         = false;
            pathFinder     = npcs.PathFinder;
            target         = new Vector3(position.X, position.Y, position.Z);
        }
Example #6
0
File: NPC.cs Project: kayorga/3DSP
        /// <summary>
        /// assigns NPC attributes and ModelObject and activates the NPC
        /// </summary>
        /// <param name="k">NPC kind/species</param>
        /// <param name="m">ModelObject</param>
        /// <param name="p">starting position</param>
        /// <param name="d">starting direction</param>
        /// <param name="l">level</param>
        /// <param name="pl">Player</param>
        /// <param name="npcs">parent NPCCollection (should always be "this")</param>
        public void setup(byte k, ModelObject m, Vector3 p, Vector3 d, int l, Player pl, NPCCollection npcs, byte elem = Constants.ELM_NIL)
        {
            kind = k;
            model = m;
            position = p;
            direction = d;
            level = l;

            if (kind == Constants.NPC_BOSS)
                level = Math.Min(60, Math.Max(1, level));
            else level = Math.Min(50, Math.Max(1, level));

            playerDistance = (pl.Position - this.Position).Length();

            #region kind specific stats
            switch (kind)
            {
                case Constants.NPC_NONE:
                    speed = 0.03f;
                    maxHealth = (int)(50 * Math.Pow(1.05f, level - 1));
                    XP = 2;
                    maxCooldn = 70;
                    model.Scaling = new Vector3(0.75f, 0.75f, 0.75f);
                    element = Constants.ELM_NIL;
                    strength = (byte)(10 * Math.Pow(1.045f, level - 1));
                    break;
                case Constants.NPC_PLAS:
                    speed = 0.035f;
                    maxHealth = (int)(50 * Math.Pow(1.045f, level - 1));
                    XP = 3;
                    maxCooldn = 80;
                    model.Scaling = new Vector3(0.75f, 0.75f, 0.75f);
                    element = Constants.ELM_PLA;
                    strength = (byte)(10 * Math.Pow(1.05f, level - 1));
                    break;
                case Constants.NPC_HEAT:
                    speed = 0.04f;
                    maxHealth = (int)(50 * Math.Pow(1.04f, level - 1));
                    XP = 3;
                    maxCooldn = 75;
                    model.Scaling = new Vector3(0.5f, 0.5f, 0.5f);
                    element = Constants.ELM_HEA;
                    strength = (byte)(10 * Math.Pow(1.055f, level - 1));
                    break;
                case Constants.NPC_ICE:
                    speed = 0.03f;
                    maxHealth = (int)(50 * Math.Pow(1.055f, level - 1));
                    XP = 3;
                    maxCooldn = 90;
                    model.Scaling = new Vector3(0.75f, 0.75f, 0.75f);
                    element = Constants.ELM_ICE;
                    strength = (byte)(10 * Math.Pow(1.04f, level - 1));
                    break;
                case Constants.NPC_BOSS:
                    speed = 0.02f;
                    maxHealth = (int)(200 * Math.Pow(1.07f, level - 1));
                    XP = 70;
                    maxCooldn = 50;
                    model.Scaling = new Vector3(0.75f, 0.75f, 0.75f);
                    element = elem;
                    strength = (byte)Math.Min((10 * Math.Pow(1.06f, level - 1)), 255);
                    break;
                default:
                    speed = 0.001f;
                    maxHealth = 1;
                    XP = 0;
                    maxCooldn = 1000;
                    break;
            }
            #endregion

            health = maxHealth;
            active = true;
            model.Position = this.position;
            moving = false;
            newTarget = false;
            isHit = false;
            hitTimer = 0;
            isDead = false;
            pathFinder = npcs.PathFinder;
            target = new Vector3(position.X, position.Y, position.Z);
        }