Пример #1
0
    public bool UsePickup(PlayerController pc)
    {
        if (pc.WillColliderHeightCollide(transform.position, Settings.GetCombinedGroupWithPlayer(pc).CharacterSettings.ColliderHeight))
        {
            FailureIndicator.ShowFailureMessage("Not Enough Room", transform.position);
            return(false);
        }

        if (Settings.GetCombinedGroupWithPlayer(pc) == pc.CurrentSetting)
        {
            FailureIndicator.ShowFailureMessage("Already Have That Body Part", transform.position);
            return(false);
        }

        var overlap = Settings.GetOverlapGroupWithPlayer(pc);

        Settings.ApplyToPlayer(pc);
        pc.SetPositionToPickup(this);

        if (overlap.Head || overlap.Torso || overlap.Legs)
        {
            Settings = overlap;
        }
        else
        {
            Destroy(gameObject);
        }
        AudioManager.PlayOneShot(GameSettings.PickupPartSFX);
        return(true);
    }
Пример #2
0
    public SkeletonSettingGrouping GetCombinedGroupWithPlayer(PlayerController pc, SkeletonSettingGrouping lastSetting = null)
    {
        lastSetting = lastSetting ?? pc.CurrentSetting;
        bool combinedHead  = Head || (lastSetting?.Head ?? false);
        bool combinedTorso = Torso || (lastSetting?.Torso ?? false);
        bool combinedLegs  = Legs || (lastSetting?.Legs ?? false);
        bool combinedWings = Wings || (lastSetting?.Wings ?? false);
        var  resultGroup   = FindGroupingSetting(combinedHead, combinedTorso, combinedLegs, combinedWings);

        return(resultGroup);
    }
Пример #3
0
    public SkeletonSettingGrouping GetOverlapGroupWithPlayer(PlayerController pc, SkeletonSettingGrouping lastSetting = null)
    {
        lastSetting = lastSetting ?? pc.CurrentSetting;
        bool overlapHead  = Head && (lastSetting?.Head ?? false);
        bool overlapTorso = Torso && (lastSetting?.Torso ?? false);
        bool overlapLegs  = Legs && (lastSetting?.Legs ?? false);
        bool overlapWings = Wings && (lastSetting?.Wings ?? false);
        var  resultGroup  = FindGroupingSetting(overlapHead, overlapTorso, overlapLegs, overlapWings);

        return(resultGroup);
    }
Пример #4
0
    private void SpawnPickup(SkeletonSettingGrouping setting, int ind)
    {
        var go = Instantiate(GameSettings.PickupPrefab);

        go.GetComponent <BodyPickup>().Settings = setting;
        go.transform.position = transform.position;
        go.GetComponent <SpriteRenderer>().flipX = _sRend.flipX;
        var   be   = go.GetComponent <BaseEntity>();
        float xVel = (_sRend.flipX ? 1 : -1) * (ind % 2 == 0 ? 1 : -1) * (Mathf.CeilToInt(ind / 2f)) * xRandSpawnVel;  //Leaving in "throw body away" code just in case I need it later...

        xVel *= Random.Range(.8f, 1.2f);
        be.SetXVelocity(xVel);
        be.SetYVelocity(Random.Range(minYRandSpawnVel, maxYRandSpawnVel));
    }
Пример #5
0
    private void DiscardPowerup()
    {
        if (CurrentSetting.GetNumPowerups() <= 1)
        {
            FailureIndicator.ShowFailureMessage("No Body Part To Drop", transform.position);
            return;
        }
        AudioManager.PlayOneShot(GameSettings.DiscardPartSFX);
        int ind = 1;

        if (CurrentSetting.Head)
        {
            SpawnPickup(SkeletonSettingGrouping.FindGroupingSetting(true, false, false, false), ind++);
            SkeletonSettingGrouping.FindGroupingSetting(false, CurrentSetting.Torso, CurrentSetting.Legs, CurrentSetting.Wings).ForceApplyToPlayer(this);
            return;
        }
        if (CurrentSetting.Torso)
        {
            SpawnPickup(SkeletonSettingGrouping.FindGroupingSetting(false, true, false, false), ind++);
            SkeletonSettingGrouping.FindGroupingSetting(CurrentSetting.Head, false, CurrentSetting.Legs, CurrentSetting.Wings).ForceApplyToPlayer(this);
            return;
        }
        if (CurrentSetting.Legs)
        {
            SpawnPickup(SkeletonSettingGrouping.FindGroupingSetting(false, false, true, false), ind++);
            SkeletonSettingGrouping.FindGroupingSetting(CurrentSetting.Head, CurrentSetting.Torso, false, CurrentSetting.Wings).ForceApplyToPlayer(this);
            return;
        }
        if (CurrentSetting.Wings)
        {
            SpawnPickup(SkeletonSettingGrouping.FindGroupingSetting(false, false, false, true), ind++);
            SkeletonSettingGrouping.FindGroupingSetting(CurrentSetting.Head, CurrentSetting.Torso, CurrentSetting.Legs, false).ForceApplyToPlayer(this);
            return;
        }

        //Just in case
        GameSettings.GhostSetting.ForceApplyToPlayer(this);
    }
Пример #6
0
 public void ApplyToPlayer(PlayerController pc, SkeletonSettingGrouping lastSetting = null)
 {
     GetCombinedGroupWithPlayer(pc, lastSetting).ForceApplyToPlayer(pc);
 }