예제 #1
0
    public PlayerModel GetPlayerPursuit()
    {
        List <PathfindingNode> fov = Pathfinding.GetFieldOfView(pirateModel.GetSpace(), pirateModel.GetDetectRange() * 2, map);

        foreach (PathfindingNode node in fov)
        {
            if (node.GetSpace().GetPlayer() != null)
            {
                return(node.GetSpace().GetPlayer());
            }
        }
        // Outside for loop, no players found
        return(null);
    }
예제 #2
0
    // Same as above for a Space GameObject
    public void CreatePirateView(PirateModel pirateModel)
    {
        // Creates the player GameObject in the correct position.
        GameObject pirateView = UnityEngine.Object.Instantiate(GameController.GetPirateView(),
                                                               pirateModel.GetSpace().GetController().GetPosition(), Quaternion.identity, MapContainer);

        // Gets the controller from the GameObject.
        PirateController pirateController = pirateView.GetComponentInChildren <PirateController>();

        // Lets the Controller access the GameObject
        pirateController.SetShipView(pirateView);
        // Lets the Controller access the Model
        pirateController.SetModel(pirateModel, GameController.soundController);
        // Lets the Model access the Controller, as a callback
        pirateModel.SetController(pirateController);
    }