Exemple #1
0
        public void PickUp(Collider2D other)
        {
            if (!other.CompareTag("Player"))
            {
                return;
            }

            if (this.OnPickup != null)
            {
                this.OnPickup.Invoke(other);
            }

            if (this.IsWeapon)
            {
                AttackSpawner pickupAttackSpawner = GetComponent <AttackSpawner>();
                if (pickupAttackSpawner != null)
                {
                    ReplaceAttackSpawner(other.gameObject, pickupAttackSpawner);
                }
            }

            if (this.PickupSound != null)
            {
                AudioPlayer.Play(this.PickupSound, false);
            }

            if (this.DestroyOnPickup)
            {
                Destroy(this.gameObject);
            }
        }
Exemple #2
0
        public void ReplaceAttackSpawner(GameObject target, AttackSpawner attackSpawner)
        {
            AttackSpawner existingAttackSpawner = target.GetComponent <AttackSpawner>();

            bool shouldEnable = true;

            if (existingAttackSpawner != null)
            {
                shouldEnable = existingAttackSpawner.enabled;
                //Destroy(existingAttackSpawner);
            }

            AttackSpawner createdAttackSpawner = attackSpawner.CopyComponentTo(target);

            createdAttackSpawner.enabled = shouldEnable;
        }
        public void MimicPlayer()
        {
            AttackSpawner existingAttackSpawner = this.AttackSpawner;
            AttackSpawner playerAttackSpawner   = GameManager.Player.GetComponent <AttackSpawner>();

            if (existingAttackSpawner.AttackToSpawn.name == playerAttackSpawner.AttackToSpawn.name)
            {
                return;
            }

            //string playerVariableValue = this.PsiEvent.GameLevel.GetVariable("player").DataValue;
            //this.PsiEvent.GameLevel.SetVariable("response", playerVariableValue);

            bool shouldEnable = true;

            if (existingAttackSpawner != null)
            {
                shouldEnable = existingAttackSpawner.enabled;
            }

            AttackSpawner createdAttackSpawner = playerAttackSpawner.CopyComponentTo(this.Psi);

            createdAttackSpawner.enabled = shouldEnable;
        }