Example #1
0
 private void OnTriggerExit2D(Collider2D collision)
 {
     if (collision.gameObject.tag == "Player")
     {
         PirateController playerScript = collision.gameObject.GetComponent <PirateController>();
         playerScript.Respawn();
     }
 }
Example #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);
    }
Example #3
0
    private void Awake()
    {
        context = new StageContext();

        calmnessStrategy  = calmnessObj.GetComponent <CalmnessStrategy>();
        frenzyStrategy    = frenzyObj.GetComponent <FrenzyStrategy>();
        reanimateStrategy = reanimateObj.GetComponent <ReanimateStrategy>();
        demolishStrategy  = demolishObj.GetComponent <DemolishStrategy>();


        player = GameObject.Find("Player2").GetComponent <PirateController>();

        currentState = State.Calmness;
        context.setStrategy(calmnessStrategy);
        context.executeStrategy();
    }
Example #4
0
        private void InitializePirates(
            ControllersStorage controllers, GameModel model,
            IActionSystem actionSystem,
            HeroController hero)
        {
            PiratesViewFabric viewFabric = new PiratesViewFabric();

            for (int i = 0; i < model.Pirates.Length; ++i)
            {
                var pirate = new PirateController(
                    model.Pirates[i], viewFabric.CreateGameObject(), actionSystem, hero);
                pirate.SelectAction(0);

                controllers.Add(pirate);
            }
        }
Example #5
0
 public void SetController(PirateController controller)
 {
     this.pirateController = controller;
     base.SetController(controller);
     pirateController.SetSprite(type);
 }
Example #6
0
 public void SetPlayer(PirateController pirate)
 {
     pirate.Active = true;
     Camera.Target = pirate.transform;
 }
Example #7
0
 // Start is called before the first frame update
 void Start()
 {
     player      = GameObject.Find("Player2").GetComponent <PirateController>();
     audioSource = GameObject.Find("Player2").GetComponent <AudioSource>();
     StartCoroutine("SelfDestroy");
 }