示例#1
0
        /// <summary>
        /// Load content for the screen.
        /// </summary>
        /// <param name="GraphicInfo"></param>
        /// <param name="factory"></param>
        /// <param name="contentManager"></param>
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            RegisterDebugDrawCommand rc = new RegisterDebugDrawCommand(ddrawer);

            CommandProcessor.getCommandProcessor().SendCommandAssyncronous(rc);
            dlines = new DebugLines();
            ddrawer.AddShape(dlines);

            Picking pick = new Picking(this, 2000);

            pick.OnPickedLeftButton += new OnPicked(pick_OnPickedLeftButton);

            {
                SimpleModel simpleModel = new SimpleModel(factory, "Model//block");
                simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.White), TextureType.DIFFUSE);
                ///Physic info (position, rotation and scale are set here)
                BoxObject tmesh = new BoxObject(Vector3.Zero, 1, 1, 1, 10, new Vector3(1000, 1, 1000), Matrix.Identity, MaterialDescription.DefaultBepuMaterial());
                tmesh.isMotionLess = true;
                ///Forward Shader (look at this shader construction for more info)
                ForwardXNABasicShader shader = new ForwardXNABasicShader();
                ///Deferred material
                ForwardMaterial fmaterial = new ForwardMaterial(shader);
                ///The object itself
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                ///Add to the world
                this.World.AddObject(obj);
            }

            wh = new WaypointHandler();
            wh.LoadConnectedWaypoints("waypoints.xml");
            start = wh.CurrentWaypointsCollection.GetWaypointsList()[0];

            {
                ///Procedural yellow diffuse texture
                SimpleModel sm = new SimpleModel(factory, "Model\\block");
                sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Yellow), TextureType.DIFFUSE);
                ///physic Ghost object(no collision)
                GhostObject           pi  = new GhostObject(start.WorldPos, Matrix.Identity, new Vector3(5));
                ForwardXNABasicShader s   = new ForwardXNABasicShader();
                ForwardMaterial       mat = new ForwardMaterial(s);
                IObject obj4 = new IObject(mat, sm, pi);
                this.World.AddObject(obj4);
            }

            ///add a camera
            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));

            {
                SimpleModel sm = new SimpleModel(factory, "Model\\block");
                sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Blue), TextureType.DIFFUSE);
                GhostObject           pi  = new GhostObject(start.WorldPos, Matrix.Identity, new Vector3(5));
                ForwardXNABasicShader s   = new ForwardXNABasicShader();
                ForwardMaterial       mat = new ForwardMaterial(s);
                IObject obj4 = new IObject(mat, sm, pi);
                obj4.OnUpdate += new OnUpdate(obj4_OnUpdate);
                this.World.AddObject(obj4);
            }
        }
示例#2
0
 public Waypoint(WaypointType type, WaypointHandler h, Vector2 tileCoords, float depth)
 {
     Type = type;
     handler = h;
     TileCoords = tileCoords;
     if (type == WaypointType.Lift)
         BoundingRectangle = new BoundingBox(new Vector3(tileCoords.X, tileCoords.Y, depth), new Vector3(tileCoords.X + 300, tileCoords.Y + 40, depth));
     else
         BoundingRectangle = new BoundingBox(new Vector3(tileCoords.X, tileCoords.Y, depth), new Vector3(tileCoords.X + 60, tileCoords.Y + 40, depth));
 }
示例#3
0
 void ClearSelectedEntityWaypoints()
 {
     foreach (GameObject entity in selectedObjects)
     {
         WaypointHandler WH = entity.GetComponent <WaypointHandler>();
         if (WH)
         {
             WH.ClearWaypoints();
         }
     }
 }
示例#4
0
 private void Start()
 {
     chooseName();
     StudentSpeed = 1f;
     foreach (Transform child in appartment.transform)
     {
         if (child.name == "Waypoints")
         {
             waypoints = child.GetComponent <WaypointHandler>();
         }
     }
 }
        /// <summary>
        /// Load content for the screen.
        /// </summary>
        /// <param name="GraphicInfo"></param>
        /// <param name="factory"></param>
        /// <param name="contentManager"></param>
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            RegisterDebugDrawCommand rc = new RegisterDebugDrawCommand(ddrawer);

            CommandProcessor.getCommandProcessor().SendCommandAssyncronous(rc);
            dlines = new DebugLines();
            ddrawer.AddShape(dlines);

            Picking pick = new Picking(this, 2000);

            pick.OnPickedLeftButton += new OnPicked(pick_OnPickedLeftButton);

            wh = new WaypointHandler();

            SimpleModel simpleModel = new SimpleModel(factory, "Model//block");

            simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.White), TextureType.DIFFUSE);
            ///Physic info (position, rotation and scale are set here)
            BoxObject tmesh = new BoxObject(Vector3.Zero, 1, 1, 1, 10, new Vector3(1000, 1, 1000), Matrix.Identity, MaterialDescription.DefaultBepuMaterial());

            tmesh.isMotionLess = true;
            ///Forward Shader (look at this shader construction for more info)
            ForwardXNABasicShader shader = new ForwardXNABasicShader();
            ///Deferred material
            ForwardMaterial fmaterial = new ForwardMaterial(shader);
            ///The object itself
            IObject obj = new IObject(fmaterial, simpleModel, tmesh);

            ///Add to the world
            this.World.AddObject(obj);

            {
                InputPlayableKeyBoard ipk = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, Microsoft.Xna.Framework.Input.Keys.Space);
                ipk.KeyStateChange += new KeyStateChange(ipk_KeyStateChange);
                this.BindInput(ipk);
            }

            {
                InputPlayableKeyBoard ipk = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, Microsoft.Xna.Framework.Input.Keys.Enter);
                ipk.KeyStateChange += new KeyStateChange(ipk_KeyStateChange2);
                this.BindInput(ipk);
            }

            ///add a camera
            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
        }
示例#6
0
 void ClearSelectedEntityAttackTargets()
 {
     foreach (GameObject entity in selectedObjects)
     {
         WaypointHandler WH = entity.GetComponent <WaypointHandler>();
         if (WH)
         {
             if (WH.mode == WaypointHandlerMode.ONLINE)
             {
                 ClientGameRunner.Instance.IssueComand(entity.GetComponent <IUnit>(), null);
             }
             else
             {
                 WH.entityController.ClearAttackTarget();
             }
         }
     }
 }
示例#7
0
    public void Initialize()
    {
        ghosts = new List <Ghost>();
        blinky = Instantiate(blinkyPrefab) as Ghost;
        inky   = Instantiate(inkyPrefab) as Ghost;
        pinky  = Instantiate(pinkyPrefab) as Ghost;
        clyde  = Instantiate(clydePrefab) as Ghost;
        waypointHandlerInstance = Instantiate(waypointHandler) as WaypointHandler;

        blinky.Initialize(waypointHandlerInstance.GetWaypoints(GhostType.Blinky));
        inky.Initialize(waypointHandlerInstance.GetWaypoints(GhostType.Inky));
        pinky.Initialize(waypointHandlerInstance.GetWaypoints(GhostType.Pinky));
        clyde.Initialize(waypointHandlerInstance.GetWaypoints(GhostType.Clyde));

        ghosts.Add(blinky);
        ghosts.Add(inky);
        ghosts.Add(pinky);
        ghosts.Add(clyde);
    }
示例#8
0
 void SetSelectedEntityAttackTargets(IUnit target)
 {
     foreach (GameObject entity in selectedObjects)
     {
         Debug.Log("Setting attack target...");
         WaypointHandler WH = entity.GetComponent <WaypointHandler>();
         if (WH && !ClientGameRunner.Instance.IsOurUnit(target.GetGameObject()))
         {
             if (WH.mode == WaypointHandlerMode.ONLINE)
             {
                 Debug.Log("Issued attack cmd");
                 ClientGameRunner.Instance.IssueComand(entity.GetComponent <IUnit>(), target);
             }
             else
             {
                 WH.entityController.SetAttackTarget(target);
             }
         }
     }
 }
示例#9
0
    // Handle the ray casting portion of selecting entities using individual (one-by-one) selection
    bool SetAttackTarget()
    {
        bool       hitEnemy = false;
        RaycastHit hitResult;
        GameObject selectedObject;

        if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hitResult))
        {
            selectedObject = hitResult.collider.gameObject;
            WaypointHandler WH = selectedObject.GetComponent <WaypointHandler>();
            if (WH)    // Check if hit result is an entity object. DO THIS BETTER.
            {
                if (selectedObjects.Count > 0)
                {
                    SetSelectedEntityAttackTargets((IUnit)WH.entityController);
                    hitEnemy = true;
                    Debug.Log("Hit with raycast enemy");
                }
            }
        }

        return(hitEnemy);
    }
 // Use this for initialization
 void Awake()
 {
     handler        = GetComponent <WaypointHandler> ();
     requestManager = GetComponent <PathRequestManager> ();
 }