コード例 #1
0
        void TryPickupBodyPart(LimbType type)
        {
            List <LimbPickup> touchedParts = new List <LimbPickup>();
            List <LimbPickup> allParts     = LimbManager.Instance.GetLimbs();

            //collide all parts
            for (int i = 0; i < allParts.Count; i++)
            {
                LimbPickup part = allParts[i];
                if (part.blob.Collides(blob))
                {
                    touchedParts.Add(part);
                }
            }

            //test for matching limb
            for (int i = 0; i < touchedParts.Count; i++)
            {
                LimbPickup part = touchedParts[i];
                Limb       limb = part.blob.GetComponent <Limb>();

                if (limb.IsMatchingLimb(type))
                {
                    part.Pickup();
                    AddLimbFromLimb(type, limb);
                    AttachAbilityToPart(type, limb);
                    SoundManager.PlaySound(SoundManager.SFX_ATTACH_LIMB);
                    return;
                }
            }
        }
コード例 #2
0
    // Start is called before the first frame update
    void Start()
    {
        animator        = GetComponent <Animator>();
        characterHealth = GetComponent <CharacterHealth>();

        animator.Play("Idle");
        moveMode      = MoveMode.Crawling;
        limbComponent = GetComponentInChildren <LimbPickup>();

        // Event Listeners
        characterHealth.healthChange.AddListener(Hurt);

        ChangeState(PlayerState.ACTIVE);
        currentSpeed = 0.0f;
    }
コード例 #3
0
ファイル: DieInSeconds.cs プロジェクト: nsparisi/n3-games
        public override void Update()
        {
            base.Update();

            lifeSeconds -= Time.deltaTime;
            if (lifeSeconds <= 0f)
            {
                LimbPickup limbPickup = blob.GetComponent <LimbPickup>();
                if (limbPickup != null)
                {
                    limbPickup.Remove();
                }
                blob.transform.Parent = null;
                blob.Destroy();
            }
        }