Exemple #1
0
        public override void OnBeingSelected()
        {
            _lastShootTime = Time.time;
            Transform holderParent = weaponHolder.transform.parent;

            weaponHolder.transform.SetParent(null);
            weaponHolder.GetComponent <MeshFilter>().sharedMesh       = PickUpPrefab.GetComponent <MeshFilter>().sharedMesh;
            weaponHolder.GetComponent <MeshRenderer>().sharedMaterial = PickUpPrefab.GetComponent <MeshRenderer>().sharedMaterial;
            weaponHolder.transform.localScale = PickUpPrefab.transform.localScale;
            weaponHolder.transform.parent     = holderParent;
            GetComponent <PlayerAnimation>().SetWeaponType(holdingType);
            attackSpawnPosition.localPosition = PickUpPrefab.transform.FindDeepChild("AttackSpawnPoint").transform.localPosition;
            _bulletSpawnPosition = attackSpawnPosition;
        }
Exemple #2
0
    /// <summary>
    /// This is the start of the Event-Chain for Game Score, health to be changed
    /// </summary>
    /// <param name="collision">Collision.</param>
    private void OnTriggerEnter2D(Collider2D collision)
    {
        Debug.Log("Collided with something");
        //check tag on gameObject that has this collider on it
        if (collision.CompareTag("Collectible"))
        {
            //get the PickUp component from the gameObject with this collider on it
            PickUpPrefab item = collision.GetComponent <PickUpPrefab>();
            Debug.Log("collided with a collectible of value: " + item.Value);

            GameData.instanceRef.Add(item.Value);
            Destroy(collision.gameObject); //destroy GameObject of the object we collided with
        }
        else if (collision.CompareTag("Hazard"))
        {
            PickUpPrefab item = collision.GetComponent <PickUpPrefab>();
            Debug.Log("collided with a hazard of value: " + item.Value);
            //update gameData database

            GameData.instanceRef.TakeDamage(item.Value);
            Destroy(collision.gameObject); //destroy GameObject of the object we collided with
        }
    }