private void OnTriggerEnter2D(Collider2D collision) { // See if collision is an encounter ChanceEncounter encounter = collision.gameObject.GetComponent <ChanceEncounter>(); if (encounter != null && (gameState == Game.State.CATCHING && MainSceneController.GetInstance().GetState() == Game.State.CATCHING)) { Encounter generatedEncounter = encounter.GenerateEncounter(); /* * Debug.Log("========================================================="); * Debug.Log("Encounter :: " + collision.gameObject.name); * Debug.Log("Generated :: " + generatedEncounter); * Debug.Log("========================================================="); */ GameController.Encounter = generatedEncounter; MainSceneController.GetInstance().SetState(Game.State.ENCOUNTER_QUERY); // Notify controller to show encounter frame } }
// Update is called once per frame void Update() { // Slow if space is held or user not pressing movement keys if (Input.GetKey(KeyCode.Space) || (Input.GetAxis("Horizontal") == 0 && Input.GetAxis("Vertical") == 0)) { if (!braking) { brakeTimer = 0; originalVelocity = playerRigidbody.velocity; braking = true; } playerRigidbody.velocity = Vector2.Lerp(originalVelocity, Vector2.zero, brakeTimer); brakeTimer += Time.deltaTime / brakeTime; } else { braking = false; if (MainSceneController.GetInstance().GetState() == Game.State.CATCHING) { // Get and normalise input Vector2 moveInput = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical")); moveVelocity = moveInput.normalized * speed; // Set rotation to follow velocity if (moveVelocity.x != 0 || moveVelocity.y != 0) { Vector3 vectorToTarget = (transform.position + new Vector3(moveVelocity.x, moveVelocity.y)) - transform.position; float angle = Mathf.Atan2(vectorToTarget.y, vectorToTarget.x) * Mathf.Rad2Deg; Quaternion q = Quaternion.AngleAxis(angle, Vector3.forward); transform.rotation = Quaternion.Slerp(transform.rotation, q, Time.deltaTime * rotationSpeed); } } } }
void Start() { sceneController = Director.GetInstance().currentSceneController as MainSceneController; }
public void Inject(BoatRenderer boatRenderer, MainSceneController globalController) { this.boatRenderer = boatRenderer; this.globalController = globalController; }
// Use this for initialization void Awake() { ProfileManager.Instance.Load(); s_Instance = this; //Create arrays _Buildings = new List<Building>(); _Mukyas = new List<Mukya>(); _Diamonds = new List<Diamond>(); _DiamondsActive = new List<Diamond>(); _PlayerDiamonds = new int[DIAMOND_TYPES]; _OngoingResidents = new Hashtable(); //Set camera _Camera = Camera.main; _CameraDrag = _Camera.GetComponent<CameraDrag>(); //Load scene from data CreateScene(); //Default value Money = ProfileManager.Instance.Money; for(int i=0;i<DIAMOND_TYPES;i++) SetDiamond(i, ProfileManager.Instance.Diamonds[i]); //Spawn diamonds StartCoroutine(SpawnDiamonds()); //Background music StartCoroutine(StartBackgroundMusic()); }
// Start is called before the first frame update void Start() { text = GetComponentInChildren <TextMesh>(); controller = FindObjectOfType <MainSceneController>(); }
public void Inject(int id, PriestRenderer priestRenderer, MainSceneController globalController, Configs configs) { this.id = id; this.globalController = globalController; this.priestRenderer = priestRenderer; }
void Start() { this.controller = new MainSceneController(); }
void Start() { gameState = MainSceneController.GetInstance().GetState(); }
public void Inject(int id, EvilRenderer evilRenderer, MainSceneController globalController, Configs configs) { this.id = id; this.globalController = globalController; this.evilRenderer = evilRenderer; }
public PriestRenderer(int id, Vector3 pos, Materials mats, IMoveStrategy moveStrategy, MainSceneController globalController, Configs configs) { this.gameObj = GameObject.CreatePrimitive(PrimitiveType.Sphere); MeshRenderer meshRenderer = this.gameObj.GetComponent <MeshRenderer>(); meshRenderer.material = mats.Priest; Transform transform = this.gameObj.GetComponent <Transform>(); transform.position = pos; transform.localScale = configs.CharScale; PriestController localController = this.gameObj.AddComponent <PriestController>(); localController.Inject(id, this, globalController, configs); this.moveStrategy = moveStrategy; this.globalController = globalController; }
public void Awake() { PhotonNetwork.AddCallbackTarget(this); PhotonNetwork.AutomaticallySyncScene = true; instance = this; }