Esempio n. 1
0
    // Use this for initialization
    void Start()
    {
        if (this.isLocalPlayer)
        {
            ThirdPersonCamera camera = FindObjectOfType <ThirdPersonCamera>();

            // Setting bunny offset target if BunnyController exists
            BunnyController bunnyContr = GetComponent <BunnyController>();

            if (camera != null)
            {
                if (!bunnyContr)
                {
                    camera.SetTarget(this.transform);
                }
                else
                {
                    camera.SetTarget(this.transform.GetChild(2));
                }
            }
            this.tag = "Player";
            transform.GetChild(0).gameObject.SetActive(true);
        }
        else
        {
            this.tag = "Enemy";
        }
    }
Esempio n. 2
0
    public void Hit(RaycastHit castHit)
    {
        GameObject selected = spawnedObjects.Find(x => x.name.Equals(castHit.collider.name));

        if (selected != null)
        {
            BunnyController controller = selected.GetComponent <BunnyController>();
            controller.decreaseHealth();
            ParticleSystem particles = selected.GetComponentInChildren <ParticleSystem>();
            particles.transform.position = castHit.point;
            particles.Play();
            sounds[0].Play();
            if (controller.Health <= 0)
            {
                HUD.GetComponent <HUDManager>().UpdateCurrentNumberOfKills(50);
                sounds[1].Play();
                selected.GetComponent <Animator>().SetTrigger("HasDied");
                selected.GetComponent <UnityEngine.AI.NavMeshAgent>().enabled = false;
                Debug.Log("alreadyspawned: " + numberOfAlreadySpawned);
                Debug.Log("listsize: " + ListSize);
                spawnedObjects.Remove(selected);
                Debug.Log("listsize: " + ListSize);
                StartCoroutine("Deactivate", selected);
            }
        }

        // throw new NotImplementedException();
    }
Esempio n. 3
0
    // Update is called once per frame
    void Update()
    {
        if (numBuns < maxBuns)
        {
            timeTillNextBun += Time.deltaTime;

            if (timeTillNextBun >= timeBetweenBuns)
            {
                timeTillNextBun = 0;

                BunnyController bc = Instantiate(bunny, spawnLocations[Random.Range(0, spawnLocations.Length)].position, Quaternion.identity).GetComponent <BunnyController>();
                bc.bs = this;

                numBuns++;
            }
        }
    }
Esempio n. 4
0
 // Use this for initialization
 private void Awake()
 {
     m_Character = GetComponent <BunnyController> ();
 }