private void OnTriggerExit2D(Collider2D collision) { if (collision.gameObject.tag == "Player") { PirateController playerScript = collision.gameObject.GetComponent <PirateController>(); playerScript.Respawn(); } }
// 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); }
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(); }
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); } }
public void SetController(PirateController controller) { this.pirateController = controller; base.SetController(controller); pirateController.SetSprite(type); }
public void SetPlayer(PirateController pirate) { pirate.Active = true; Camera.Target = pirate.transform; }
// Start is called before the first frame update void Start() { player = GameObject.Find("Player2").GetComponent <PirateController>(); audioSource = GameObject.Find("Player2").GetComponent <AudioSource>(); StartCoroutine("SelfDestroy"); }