void OnCollisionEnter(Collision col)
 {
     //print("COLLISION");
     if (col.gameObject.name != "player")
     {
         BounceSound.Play();
     }
     if (col.gameObject.name == "skeleton_animated")
     {
         SkeletonScript skelScript = col.gameObject.GetComponent <SkeletonScript>();
         skelScript.addScore(10);
         Destroy(this.gameObject);
     }
 }
Esempio n. 2
0
    void Awake()
    {
        DontDestroyOnLoad(gameObject);
        playerCamera = GetComponentInChildren <Camera>();
        //playerMovement = GetComponent<PlayerMovement>();
        Skeleton     = GetComponent <SkeletonScript>();
        playerShoot  = GetComponent <PlayerShoot>();
        playerHealth = GetComponent <PlayerHealth>();
        tankCollider = GetComponent <Collider>();

        if (!photonView.IsMine)
        {
            DestroyImmediate(playerCamera.gameObject);
        }
    }
    // Update is called once per frame
    void Update()
    {
        // pull only one location update from the queue
        // we might want to empty out ALL such updates, but hesitant
        // to put a loop inside Update()
        // it would allow to skip/drop multiple updates to same GameObject
        if (workQueue.Count > 0)
        {
            //System.Diagnostics.Debug.WriteLine("Qcount: " + workQueue.Count);
            SkeletonData sd = workQueue.Dequeue();

            if (!allSkeletons.ContainsKey(sd.name))
            {
                // create new Skeleton
                GameObject o = Instantiate(skeletonObject, transform);
                o.name = sd.name;
                allSkeletons.Add(sd.name, o);
                SkeletonScript obj = (SkeletonScript)o.GetComponent <SkeletonScript>();
                sd.gameObj    = o;
                sd.Enabled    = true;
                obj.hasUpdate = true;
                obj.sd        = sd;
                o.SetActive(true);
            }
            else
            {
                GameObject     o   = allSkeletons[sd.name];
                SkeletonScript obj = (SkeletonScript)o.GetComponent <SkeletonScript>();

                if (sd.Enabled == true)
                {
                    sd.gameObj    = o;
                    sd.Enabled    = true;
                    obj.hasUpdate = true;
                    obj.sd        = sd;
                    o.SetActive(true);
                }
                else
                {
                    Destroy(o);
                    allSkeletons.Remove(sd.name);
                }
            }
        }
    }
Esempio n. 4
0
    void OnTriggerEnter2D(Collider2D collision) //checks for collision, this section works EXACTLY the same as a regular bullet
    {
        if (collision.gameObject.tag == "Enemy")
        {
            if (collision.gameObject.name == "SkeletonPrefab(Clone)")
            {
                SkeletonScript skeletonScript = collision.gameObject.GetComponent <SkeletonScript>();
                skeletonScript.health = skeletonScript.health - bulletDamage;
            }

            if (collision.gameObject.name == "VampirePrefab(Clone)")
            {
                VampireScript vampireScript = collision.gameObject.GetComponent <VampireScript>();
                vampireScript.health = vampireScript.health - bulletDamage;
            }

            if (collision.gameObject.name == "WitchPrefab(Clone)")
            {
                WitchScript witchScript = collision.gameObject.GetComponent <WitchScript>();
                witchScript.health = witchScript.health - bulletDamage;
            }
        }
    }
Esempio n. 5
0
 void OnTriggerEnter2D(Collider2D collision)                                                       //detect collision
 {
     if (collision.gameObject.tag == "Enemy")                                                      //check to see if what we are colliding with is an enemy
     {
         if (collision.gameObject.name == "SkeletonPrefab(Clone)")                                 //if it's a Skeleton
         {
             SkeletonScript skeletonScript = collision.gameObject.GetComponent <SkeletonScript>(); //get the Skeleton's script
             skeletonScript.health = skeletonScript.health - bulletDamage;                         //subtract the bullet's damage from the Skeleton's health
             Destroy(gameObject);                                                                  //destroy the bullet
         }
         else if (collision.gameObject.name == "VampirePrefab(Clone)")                             //if it's a Vampire
         {
             VampireScript vampireScript = collision.gameObject.GetComponent <VampireScript>();    //get the Vampire's script
             vampireScript.health = vampireScript.health - bulletDamage;                           //subtract the bullet's damage from the Vampire's health
             Destroy(gameObject);                                                                  //destroy the bullet
         }
         else if (collision.gameObject.name == "WitchPrefab(Clone)")                               //if it's a Witch
         {
             WitchScript witchScript = collision.gameObject.GetComponent <WitchScript>();          //get the Witch's script
             witchScript.health = witchScript.health - bulletDamage;                               //subtract the bullet's damage from the Witch's health
             Destroy(gameObject);                                                                  //destroy the bullet
         }
     }
 }
Esempio n. 6
0
 // Use this for initialization
 void Start()
 {
     skeletonScript = GetComponentInChildren <SkeletonScript>();
 }