void SetPickupType(int selection) { switch (selection) { case 1: renderer.material = weaponPickUp; currentType = PickUpTypes.Weapon; break; case 2: renderer.material = turboPickUp; currentType = PickUpTypes.Turbo; break; case 3: renderer.material = healthPickUp; currentType = PickUpTypes.Health; break; default: renderer.material = weaponPickUp; currentType = PickUpTypes.Weapon; break; } }
public int Count(PickUpTypes type) { int count = 0; foreach (var pickup in PickUps) { if (type == pickup) { count++; } } return(count); }
void initType(int type) { currentType = (PickUpTypes)type; if (currentType == PickUpTypes.Health) { renderer.material = healthPickUp; } if (currentType == PickUpTypes.Turbo) { renderer.material = turboPickUp; } if (currentType == PickUpTypes.Weapon) { renderer.material = weaponPickUp; } }
public void AddPickUp(PickUpTypes type) { if (networkView.isMine) { int pickupLimit = (type == PickUpTypes.Weapon) ? 2 : 1; if (Count(type) < pickupLimit) { PickUps.Add(type); if (tag == "Dino" && networkView.isMine) { myHud.UpdateItems(this); } } } }
public bool UsePickUp(PickUpTypes type, int count = 1) { int countRemoved = 0; for (int i = 0; i < count; i++) { var result = PickUps.Remove(type); if (result) { countRemoved++; } } if (countRemoved == count) { if (type == PickUpTypes.Health) { OnHealthPickupUse(); } if (type == PickUpTypes.Turbo) { OnTurboPickupUse(); } if (tag == "Dino" && networkView.isMine) { myHud.UpdateItems(this); } return(true); } for (int i = 0; i < countRemoved; i++) { PickUps.Add(type); } if (tag == "Dino" && networkView.isMine) { myHud.UpdateItems(this); } return(false); }
void Start() { pickUpRenderer = GetComponent <Renderer>(); GetComponent <Rigidbody>().velocity = transform.forward * speed; gameController = GameObject.FindObjectOfType <GameController>(); if (gameController == null) { Debug.Log("Cannot Find 'GameController' script"); } playerController = GameObject.FindObjectOfType <PlayerController>(); if (playerController == null) { Debug.Log("Cannot find 'PlayerController' script"); } if (type == PickUpTypes.random) { int chance = Random.Range(0, 4); type = (PickUpTypes)chance; pickUpRenderer.material.mainTexture = textures[chance]; } }
public void SetHealth(int healthAmount) { health = healthAmount; pickUpType = PickUpTypes.HEALTH; }
public void setType(PickUpTypes type) { networkView.RPC("initType", RPCMode.AllBuffered, (int)type); }