void RPCCollectItem(string itemType, int itemNetId, int ownerNetID) { PhotonView itemView = PhotonView.Find(itemNetId); if (itemView == null) { return; } CollectibleController item = itemView.gameObject.GetComponent <CollectibleController>(); if ((item.ownerID != -1 && item.ownerID != photonView.ViewID)) { return; } else { item.ownerID = photonView.ViewID; switch (itemType) { case "Health": playerHealthManager.SetHealth(item.collectibleValue); break; default: break; } PhotonNetwork.Destroy(PhotonView.Find(itemNetId)); } }
public void OnItemTaken() { // Item has been taken, so disable the original _originalController.gameObject.SetActive(false); CurrentItem = null; _originalController = null; }
private void Init() { if (Instance != null) { Destroy(gameObject); } else { DontDestroyOnLoad(gameObject); Instance = this; } InitPlayer(); wallObjects = GameObject.FindWithTag("WallObjects"); player = GameObject.FindWithTag("Entity/Player"); levelGenerator = GetComponent <LevelGenerator>(); poolManager = GetComponent <PoolManager>(); gameInput = GetComponent <GameInput>(); canvasManager = GameObject.FindWithTag("Manager/CanvasManager").GetComponent <CanvasManager>(); collectibleController = GameObject.FindWithTag("Manager/CollectibleController").GetComponent <CollectibleController>(); gameInput.gameController = this; gameState = GameState.DEBUG; cameraTransform = Camera.main.transform; EventManager.OnDoubleTap += OnDoubleTap; }
public void OnPrimaryDialogueButtonClick() { // This means the player wants to drop the item. _originalController.ReturnItem(); CurrentItem = null; _originalController = null; }
private CollectibleController AddCollectibleToPool() { CollectibleController newCollectible = Instantiate(collectiblePrefab, transform).GetComponent <CollectibleController>(); newCollectible.Initialize(); collectiblePool.Add(newCollectible); return(newCollectible); }
void Start() { m_collectibleController = GameObject.FindGameObjectWithTag("Collectible").GetComponent <CollectibleController>(); m_rigidbody = GetComponent <Rigidbody2D>(); m_animator = GetComponent <Animator>(); maxHP = currentHP = 100; shipColor = "Red"; currencyGained = 0; }
void Start() { levelComplete = false; rend = GetComponent <Renderer>(); rend.enabled = true; rend.sharedMaterial = material[0]; boxCollider = GameObject.Find("GoalTrigger").GetComponent <BoxCollider>(); collectibles = GameObject.Find("CollectibleController").GetComponent <CollectibleController>(); ballReset = GameObject.Find("Ball").GetComponent <BallReset>(); }
// Use this for initialization void Awake() { if (_cc == null) { _cc = this; } else { Destroy(this.gameObject); } }
void Awake() { controller = GameObject.Find("Apple System").GetComponent<CollectibleController>(); transform.parent = controller.transform; controller.appleList.Add(this); int leafAmount = Random.Range(0, (int)Mathf.Pow(2, leaves.Length)); for(int i = 0; i < leaves.Length; ++i) { leaves[i].gameObject.SetActive((leafAmount & (int)Mathf.Pow(2, i)) != 0); } }
void Start() { CollectibleController cc = GameObject.Find("Level Controller").GetComponent <CollectibleController>(); DeathController dc = GameObject.Find("Level Controller").GetComponent <DeathController>(); GameData data = GameController.instance.Data; levelMoneySumText.text = cc.levelMoneySum.ToString(); moneyTotalText.text = data.MoneyTotal.ToString(); levelDeathCountText.text = dc.levelDeathCount.ToString(); deathTotalText.text = data.DeathCount.ToString(); }
public void RegisterCollectible(CollectibleController controller) { var controllerGameObject = controller.gameObject; string sceneName = controllerGameObject.scene.name; if (!_collectibleReferences.ContainsKey(sceneName)) { _collectibleReferences.Add(sceneName, new List <CollectibleController>()); } _collectibleReferences[sceneName].Add(controller); _allCollectibles.Add(controller); }
public void RemoveDestroyed(CollectibleController cube) { for (int i = 0; i < collectiblesList.Count; i++) { if (collectiblesList[i] == cube) { collectiblesList.RemoveAt(i); } } if (collectiblesList.Count == 0) { EventManager.Instance.GameOverEvent(); } }
//void OnGUI() //{ // GUI.Box(top, cd); // GUI.Box(bottom, cu); // GUI.Box(right, cr); // GUI.Box(left, cl); //} private void OnTriggerEnter2D(Collider2D collision) { //print(collision.gameObject.layer); if (collision.gameObject.layer == 11) { CollectibleController cc = collision.gameObject.GetComponent <CollectibleController>(); print("Picked up: " + cc.type.ToString()); if (cc.type == 0) { GC.scoreVal += 100 * (int)(GC.offset); } else if (cc.type == 1) { if (health < 3) { ChangeHealth(1); } } else if (cc.type == 2) { triggerInvin(colInvinTime); } else { if (hammers < 3) { hammers += 1; } } Destroy(collision.gameObject); } else { if (!invincible) { print("Hurt"); ChangeHealth(-1); if (!dead) { triggerInvin(hurtInvinTime); } } } }
//0 - coin //1 - meds //2 - gem //3 - hammer void MakeCollectibles() { if (nextCollectible != 0) { nextCollectible -= 1; return; } List <int> open = Enumerable.Range(0, 7).Where(i => B[front][i] == '-').ToList(); if (open.Count > 0) { int pos = rc(open.ToArray()); GameObject Collectible = Instantiate(CollectiblePrefab, new Vector3(front - offset, pos, 0), Quaternion.identity).gameObject; CollectibleController collectibleController = Collectible.GetComponent <CollectibleController>(); Collectible.transform.parent = terrainObject.transform; collectibleController.parent = this; int colType = -1; if (difficulty == 0) { colType = rc(new int[] { 0 }); } if (difficulty == 1) { colType = rc(new int[] { 0, 0, 3 }); } if (difficulty == 2) { colType = rc(new int[] { 0, 0, 0, 0, 3, 3, 1 }); } if (difficulty == 3) { colType = rc(new int[] { 0, 0, 0, 3, 3, 1, 2 }); } if (CQ.Count > 0) { colType = CQ.Dequeue(); } collectibleController.type = colType; nextCollectible = 5; } }
private void OnTriggerEnter(Collider collision) { CollectibleController temp = collision.gameObject.GetComponent <CollectibleController>(); if (temp != null) { if (temp.GetCollectibleType.Equals(lastCollectibleType)) { streak++; EventManager.Instance.StreakEvent(streak); } else { lastCollectibleType = temp.GetCollectibleType; streak = 1; EventManager.Instance.StreakEvent(streak); } } }
public void CollectItem(GameObject item) { CollectibleController collController = item.GetComponent <CollectibleController>(); if (collController != null) { switch (collController.collectibleType.ToString()) { case "Health": if (playerHealthManager.GetHealth() == 100) { return; } break; default: break; } item.SetActive(false); photonView.RPC("RPCCollectItem", RpcTarget.AllViaServer, collController.collectibleType.ToString(), collController.photonView.ViewID, photonView.ViewID); } }
private void InitializeCollectibles() { int enumCount = 0; foreach (CollectibleType type in Enum.GetValues(typeof(CollectibleType))) { enumCount++; } int randomIndex; for (int i = 0; i < 10; i++) { randomIndex = UnityEngine.Random.Range(0, enumCount - 1); CollectibleController instance = Instantiate(collectiblePrefab); instance.Initialize(collectibleProp[randomIndex]); Transform temp = instance.transform; temp = GameManager.Instance.GetRandomCoordinates(); instance.transform.position = temp.position; collectiblesList.Add(instance); } }
public void FinishLevel() { CollectibleController cc = GetComponent <CollectibleController>(); DeathController dc = GetComponent <DeathController>(); GameData data = GameController.instance.Data; player.GetComponent <Player>().FinishLevel(); HudCanvas.SetActive(false); resultCanvas.SetActive(true); if (data.ReachedLevel <= levelInfo.level) { resultCanvas.GetComponent <ResultCanvas>().ShowFirstRunText(); } else { resultCanvas.GetComponent <ResultCanvas>().ShowHNotFirstRunText(); } data.MoneyTotal += cc.levelMoneySum; data.DeathCount += dc.levelDeathCount; data.ReachedLevel = levelInfo.level + 1; GameController.instance.PersistData(); }
void Start() { collectible = GetComponentInParent <CollectibleController>(); }
public static void SetCollectibleController(CollectibleController collectibleController) { CollectibleController = collectibleController; }
protected void Start() { cc = GameObject.Find("Level Controller").GetComponent <CollectibleController>(); cc.Register(gameObject); }
void Start() { view = FindObjectOfType<LevelingView>(); appleSystem = FindObjectOfType<CollectibleController>(); appleSystem.SetCanHaveApples(CanHaveApples); }
public void OnReceiveItem(CollectibleController collectible) { _originalController = collectible; CurrentItem = collectible.CollectibleProfile; }
void Awake() { if (instance == null) instance = this; }
public void setController(CollectibleController controller) { this.controller = controller; }