Ejemplo n.º 1
0
 public void Clean()
 {
     PlaceList.Clear();
     TreasureList.Clear();
     TreasureSelected = null;
     PlaceSelected    = null;
 }
Ejemplo n.º 2
0
 //切换地图
 void ChangeMap()
 {
     vec = GameKernel._instance.playerManager.player.transform.position;
     if (vec.x - x >= 300)
     {
         isChange = true;
         x       += 300;
     }
     if (vec.x - x <= -300)
     {
         isChange = true;
         x       -= 300;
     }
     if (vec.y - y >= 300)
     {
         isChange = true;
         y       += 300;
     }
     if (vec.y - y <= -300)
     {
         isChange = true;
         y       -= 300;
     }
     if (vec.z - z >= 300)
     {
         isChange = true;
         z       += 300;
     }
     if (vec.z - z <= -300)
     {
         isChange = true;
         z       -= 300;
     }
     for (int i = 0; i < 27; i++)
     {
         ListList[i].ChangeXYZ((int)vec.x, (int)vec.y, (int)vec.z);
         //若player所在地图已经改变,找出player所在地图对应的列表,将其置于首位
         if (isChange)
         {
             if (ListList[i].getList(x, y, z) != null)
             {
                 isChange = false;
                 TreasureList tl = ListList[i];
                 ListList.Remove(ListList[i]);
                 ListList.Insert(0, tl);
                 GameKernel._instance.voiceManager.ChangeAudio();
             }
         }
     }
 }
Ejemplo n.º 3
0
        public Player(Stage theStage, string label, Vector3 pos, Vector3 orientAxis,
                      float radians, TreasureList tl, string meshFile)
            : base(theStage, label, pos, orientAxis, radians, meshFile)
        {  // change names for on-screen display of current camera
            first.Name   = "First";
            follow.Name  = "Follow";
            above.Name   = "Above";
            IsCollidable = true;               // players test collision with Collidable set.
            stage.Collidable.Add(agentObject); // player's agentObject can be collided with by others.
            rotate             = 0;
            angle              = 0.01f;
            initialOrientation = agentObject.Orientation;

            this.treasures     = tl;
            this.treasureCount = 0;
        }
Ejemplo n.º 4
0
    //加载宝藏
    public void Load()
    {
        treasures = new GameObject[35];
        GameObject   go;
        TreasureList tl;

        tl = new TreasureList(0, 0, 0);
        ListList.Add(tl);
        for (int i = 0; i < 35; i++)
        {
            treasures[i] = Resources.Load("prefabs/" + (int)(i + 1)) as GameObject;
        }
        for (int i = 1; i <= 10; i++)
        {
            //go = Resources.Load("prefabs/" + Random.Range(1, 36)) as GameObject;
            go = treasures[Random.Range(0, 35)];
            GameObject gg = GameObject.Instantiate(go);
            tl.AddObject(gg);
        }
        for (int a1 = -1; a1 < 2; a1++)
        {
            for (int a2 = -1; a2 < 2; a2++)
            {
                for (int a3 = -1; a3 < 2; a3++)
                {
                    if (a1 == 0 && a2 == 0 && a3 == 0)
                    {
                        continue;
                    }
                    tl = new TreasureList(a1 * 200, a2 * 200, a3 * 200);
                    ListList.Add(tl);
                    for (int i = 1; i <= 10; i++)
                    {
                        //go = Resources.Load("prefabs/" + Random.Range(1, 36)) as GameObject;
                        go = treasures[Random.Range(0, 35)];
                        GameObject gg = GameObject.Instantiate(go);
                        tl.AddObject(gg);
                    }
                }
            }
        }
    }
Ejemplo n.º 5
0
                                    { 495, 480 } };                           // loop return

        /// <summary>
        /// Create a NPC.
        /// AGXNASK distribution has npAgent move following a Path.
        /// </summary>
        /// <param name="theStage"> the world</param>
        /// <param name="label"> name of </param>
        /// <param name="pos"> initial position </param>
        /// <param name="orientAxis"> initial rotation axis</param>
        /// <param name="radians"> initial rotation</param>
        /// <param name="meshFile"> Direct X *.x Model in Contents directory </param>
        public NPAgent(Stage theStage, string label, Vector3 pos, Vector3 orientAxis,
                       float radians, TreasureList tl, string meshFile)
            : base(theStage, label, pos, orientAxis, radians, meshFile)
        {  // change names for on-screen display of current camera
            first.Name   = "npFirst";
            follow.Name  = "npFollow";
            above.Name   = "npAbove";
            isCollidable = true;
            stage.Collidable.Add(agentObject);

            this.treasureList  = tl;
            this.treasureCount = 0;
            this.treasurePath  = false;


            // path is built to work on specific terrain, make from int[x,z] array pathNode
            path = new Path(stage, pathNode, Path.PathType.LOOP); // continuous search path
            stage.Components.Add(path);
            nextGoal = path.NextNode;                             // get first path goal
            agentObject.turnToFace(nextGoal.Translation);         // orient towards the first path goal
                                                                  // set snapDistance to be a little larger than step * stepSize
            snapDistance = (int)(1.5 * (agentObject.Step * agentObject.StepSize));
        }
Ejemplo n.º 6
0
 private void Awake()
 {
     treasureList = GameObject.FindGameObjectWithTag("GameController").GetComponent <TreasureList> ();
     spawnPoint   = this.transform;
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Set GraphicDevice display and rendering BasicEffect effect.
        /// Create SpriteBatch, font, and font positions.
        /// Creates the traceViewport to display information and the sceneViewport
        /// to render the environment.
        /// Create and add all DrawableGameComponents and Cameras.
        /// First, add all required contest:  Inspector, Cameras, Terrain, Agents
        /// Second, add all optional (scene specific) content
        /// </summary>
        protected override void LoadContent()
        {
            display = graphics.GraphicsDevice;
            effect  = new BasicEffect(display);
            // Set up Inspector display
            spriteBatch   = new SpriteBatch(display);               // Create a new SpriteBatch
            inspectorFont = Content.Load <SpriteFont> ("Consolas"); // Windows XNA && MonoGames
            // set window size
            if (runFullScreen)
            {
                graphics.IsFullScreen              = true;
                graphics.PreferredBackBufferWidth  = GraphicsDevice.DisplayMode.Width;
                graphics.PreferredBackBufferHeight = GraphicsDevice.DisplayMode.Height;
            }
            else // run with window values
            {
                graphics.PreferredBackBufferWidth  = windowWidth;
                graphics.PreferredBackBufferHeight = windowHeight;
            }
            graphics.ApplyChanges();
            // viewports
            defaultViewport          = GraphicsDevice.Viewport;
            inspectorViewport        = defaultViewport;
            sceneViewport            = defaultViewport;
            inspectorViewport.Height = InfoPaneSize * inspectorFont.LineSpacing;
            inspectorProjection      = Matrix.CreatePerspectiveFieldOfView(fov,
                                                                           inspectorViewport.Width / inspectorViewport.Height, hither, yon);
            sceneViewport.Height = defaultViewport.Height - inspectorViewport.Height;
            sceneViewport.Y      = inspectorViewport.Height;
            sceneProjection      = Matrix.CreatePerspectiveFieldOfView(fov,
                                                                       sceneViewport.Width / sceneViewport.Height, hither, yon);
            // create Inspector display
            Texture2D inspectorBackground = Content.Load <Texture2D>("inspectorBackground");

            inspector = new Inspector(display, inspectorViewport, inspectorFont, Color.Black, inspectorBackground);
            // create information display strings
            // help strings
            inspector.setInfo(0, "Academic Graphics MonoGames 3.6 Starter Kit for CSUN Comp 565 assignments.");
            inspector.setInfo(1, "Press keyboard for input (not case sensitive 'H' || 'h')   'Esc' to quit");
            inspector.setInfo(2, "Inspector toggles:  'H' help or info   'M'  matrix or info   'I'  displays next info pane.");
            inspector.setInfo(3, "Arrow keys move the player in, out, left, or right.  'R' resets player to initial orientation.");
            inspector.setInfo(4, "Stage toggles:  'B' bounding spheres, 'C' || 'X' cameras, 'T' fixed updates");
            // initialize empty info strings
            for (int i = 5; i < 20; i++)
            {
                inspector.setInfo(i, "  ");
            }
            // set blending for bounding sphere drawing
            blending = new BlendState();
            blending.ColorSourceBlend      = Blend.SourceAlpha;
            blending.ColorDestinationBlend = Blend.InverseSourceAlpha;
            blending.ColorBlendFunction    = BlendFunction.Add;
            notBlending = new BlendState();
            notBlending = display.BlendState;
            // Create and add stage components
            // You must have a TopDownCamera, BoundingSphere3D, WayPoint3D, Terrain, and Agents (player, npAgent) in your stage!
            // Place objects at a position, provide rotation axis and rotation radians.
            // All location vectors are specified relative to the center of the stage.
            // Create a top-down "Whole stage" camera view, make it first camera in collection.
            topDownCamera = new Camera(this, Camera.CameraEnum.TopDownCamera);
            camera.Add(topDownCamera);
            boundingSphere3D = Content.Load <Model>("boundingSphereV8");
            wayPoint3D       = Content.Load <Model>("100x50x100Marker"); // model for navigation node display
            // Create required entities:
            collidable = new List <Object3D>();                          // collection of objects to test for collisions
            terrain    = new Terrain(this, "terrain", "heightTexture", "colorTexture");
            Components.Add(terrain);

            //Add treasure locations and meshes to map
            treasure = new TreasureList(this, "TreasureList", "ChestClosed", false);
            Components.Add(treasure);

            // Load Agent mesh objects, meshes do not have textures
            player = new Player(this, "Chaser",
                                new Vector3(510 * spacing, terrain.surfaceHeight(510, 507), 507 * spacing),
                                new Vector3(0, 1, 0), 0.78f, treasure, "redAvatarV6"); // face looking diagonally across stage
            player.IsCollidable = true;                                                // test collisions for player
            Components.Add(player);
            npAgent = new NPAgent(this, "Evader",
                                  new Vector3(490 * spacing, terrain.surfaceHeight(490, 450), 450 * spacing),
                                  new Vector3(0, 1, 0), 0.0f, treasure, "magentaAvatarV6"); // facing +Z
            npAgent.IsCollidable = true;                                                    // npAgent does not test for collisions
            Components.Add(npAgent);

            CollisionDetectors detector = new CollisionDetectors(this, "wall", "100x100x100Brick", npAgent.AgentObject.Translation, npAgent);

            detector.IsCollidable = true;
            Components.Add(detector);

            // create file output stream for trace()
            fout  = new StreamWriter("trace.txt", false);
            Trace = string.Format("{0} trace output from AGMGSKv8", DateTime.Today.ToString("MMMM dd, yyyy"));
            //  ------ The wall and pack are required for Comp 565 projects, but not AGMGSK   ---------
            // create walls for navigation algorithms
            Wall wall = new Wall(this, "wall", "100x100x100Brick");

            Components.Add(wall);
            // create a pack for "flocking" algorithms
            // create a Pack of 6 dogs centered at (450, 500) that is leaderless
            Pack pack = new Pack(this, "dog", "dogV6", 6, 450, 430, null);

            Components.Add(pack);
            // ----------- OPTIONAL CONTENT HERE -----------------------
            // Load content for your project here
            // create a temple
            Model3D m3d = new Model3D(this, "temple", "templeV3");

            m3d.IsCollidable = true;                    // must be set before addObject(...) and Model3D doesn't set it
            m3d.addObject(new Vector3(340 * spacing, terrain.surfaceHeight(340, 340), 340 * spacing),
                          new Vector3(0, 1, 0), 0.79f); // , new Vector3(1, 4, 1));
            Components.Add(m3d);
            // create 20 clouds
            Cloud cloud = new Cloud(this, "cloud", "cloudV3", 20);

            // Set initial camera and projection matrix
            setCamera(1);      // select the "whole stage" camera
            Components.Add(cloud);
            // Describe the scene created
            Trace = string.Format("scene created:");
            Trace = string.Format("\t {0,4:d} components", Components.Count);
            Trace = string.Format("\t {0,4:d} collidable objects", Collidable.Count);
            Trace = string.Format("\t {0,4:d} cameras", camera.Count);
        }
Ejemplo n.º 8
0
        private void CalcTreasure()
        {
            if (this.CustomList.Count < 1 || GrandcypherClient.Current.TreasureHooker.CurrentTreasureList == null)
            {
                return;
            }

            this.TreasureList = new List <TreasureInfo>();
            List <TreasureInfo> temp_lst = new List <TreasureInfo>();

            foreach (var item in this.CustomList)
            {
                var customtemp = item.GetMaterialList();
                temp_lst = temp_lst.Concat(customtemp).ToList();
            }
            foreach (var item in temp_lst)
            {
                TreasureInfo treasure_temp = new TreasureInfo();
                if (TreasureList.Any(x => x.ItemID == item.ItemID))
                {
                    TreasureList.Find(x => x.ItemID == item.ItemID).max += item.max;
                }
                else
                {
                    treasure_temp.Name   = item.Name;
                    treasure_temp.max    = item.max;
                    treasure_temp.ItemID = item.ItemID;
                    TreasureList.Add(treasure_temp);
                }
            }
            List <TreasureInfo> calcList = new List <TreasureInfo>();

            //GrandcypherClient.Current.TreasureHooker.CurrentTreasureList.Values= 현재 트래저 목록
            //TreasureList= 설정에 따라 불러온 트래저 목록
            foreach (var current in GrandcypherClient.Current.TreasureHooker.CurrentTreasureList.Values)
            {
                foreach (var target in TreasureList)
                {
                    if (target.ItemID == current.ItemID)
                    {
                        TreasureInfo temp_t = new TreasureInfo();

                        temp_t.Name   = current.Name;
                        temp_t.result = target.max - current.count;
                        temp_t.ItemID = current.ItemID;

                        if (temp_t.result > 0)
                        {
                            calcList.Add(temp_t);
                        }
                    }
                }
            }
            List <TreasureInfo> modified_list = new List <TreasureInfo>(calcList);

            foreach (var item in TreasureList)
            {
                if (GrandcypherClient.Current.TreasureHooker.CurrentTreasureList.Values.Where(x => x.ItemID == item.ItemID).FirstOrDefault() == default(TreasureInfo))
                {
                    TreasureInfo temp_t = new TreasureInfo();

                    temp_t.Name   = item.Name;
                    temp_t.result = item.max;
                    temp_t.ItemID = item.ItemID;
                    if (temp_t.result > 0)
                    {
                        modified_list.Add(temp_t);
                    }
                }
            }
            this.TreasureList = new List <TreasureInfo>(modified_list);
        }