Exemplo n.º 1
0
	public void StartDashAnimation(bool backwards) {
		preDashSpeed = Mathf.Abs(rb2d.velocity.x);

		// back dash animation always comes from the initial dash, where the speed boost has already been applied
		float newSpeed = (backwards ? preDashSpeed : preDashSpeed+dashSpeed);
		
		Vector2 targetVelocity = new Vector2(
			ForwardScalar() * newSpeed, 
			groundData.grounded ? 0 : Mathf.Max(rb2d.velocity.y, 0)
		);

		rb2d.velocity = targetVelocity.Rotate(groundData.normalRotation);

		if (perfectDashPossible && !earlyDashInput) {
			AlerterText.Alert("Recycling boost");
			perfectDashPossible = false;
			CancelInvoke("ClosePerfectDashWindow");
			SoundManager.ShootSound();
		}
		InterruptAttack();
		// if backwards, it'll already have been called
		// don't want a duplicate sound effect
		if (!backwards) SoundManager.DashSound();
		inMeteor = false;
		dashing = true;
		if (grounded) {
			BackwardDust();
		}
		Freeze();
		if (dashTimeout != null) StopCoroutine(dashTimeout);
	    dashTimeout = StartCoroutine(RunDashCooldown(dashCooldownLength));
	}
Exemplo n.º 2
0
    void Die(Attack fatalBlow)
    {
        if (options.gameJournalist)
        {
            AlerterText.Alert("<color=cyan>SECOND WIND</color>");
            SoundManager.HealSound();
            FullHeal();
            return;
        }

        AlerterText.AlertList(deathText);
        AlerterText.Alert($"<color=red>CAUSE OF DEATH:</color>");
        AlerterText.Alert($"<color=red>{fatalBlow.attackName}</color>");
        // if the animation gets interrupted or something, use this as a failsafe
        dead = true;
        SoundManager.PlayerDieSound();
        currentEnergy = 0;
        CameraShaker.Shake(0.2f, 0.1f);
        LockInSpace();
        Freeze();
        anim.SetTrigger("Die");
        anim.SetBool("TouchingWall", false);
        deathEvent.Raise();
        InterruptEverything();
        EndCombatStanceCooldown();
        ResetAttackTriggers();
    }
Exemplo n.º 3
0
    public static void AddItem(StoredItem s, bool quiet = false)
    {
        Item item = s.item;

        if (!quiet)
        {
            SoundManager.ItemGetSound();
            if (!item.IsType(ItemType.ABILITY))
            {
                if (s.count != 1)
                {
                    AlerterText.Alert($"{item.name} ({s.count}) acquired");
                }
                else
                {
                    AlerterText.Alert(item.name + " acquired");
                }
            }
        }
        if (item.gameStates != null)
        {
            AddStates(item.gameStates);
        }
        inventory.AddItem(s, quiet);
        PropagateItemChange();
    }
Exemplo n.º 4
0
 public static void SaveGame(bool autosave = false)
 {
     if (save.unlocks.HasAbility(Ability.Heal) && !autosave)
     {
         AlerterText.Alert("Rebuilding waveform");
         pc.FullHeal();
     }
     if (autosave)
     {
         AlerterText.AlertImmediate("Autosaving...");
     }
     save.currentHP        = pc.currentHP;
     save.maxHP            = pc.maxHP;
     save.currentEnergy    = pc.currentEnergy;
     save.maxEnergy        = pc.maxEnergy;
     save.basePlayerDamage = pc.baseDamage;
     save.playerPosition   = pc.transform.position;
     save.sceneName        = SceneManager.GetActiveScene().path;
     gc.GetComponentInChildren <MapFog>().SaveCurrentMap();
     gc.saveContainer.WriteToDiskSlot(saveSlot);
     if (autosave)
     {
         AlerterText.AlertImmediate("Autosave complete");
     }
 }
    public void StartDashAnimation(bool backwards)
    {
        preDashSpeed = Mathf.Abs(rb2d.velocity.x);
        float newSpeed = ((backwards ? 0 : preDashSpeed) + dashSpeed);

        rb2d.velocity = new Vector2(
            ForwardScalar() * newSpeed,
            Mathf.Max(rb2d.velocity.y, 0)
            );
        if (perfectDashPossible && !earlyDashInput)
        {
            AlerterText.Alert("Recycling DASH velocity");
            perfectDashPossible = false;
            CancelInvoke("ClosePerfectDashWindow");
            this.GainEnergy(1);
            SoundManager.ShootSound();
        }
        SoundManager.DashSound();
        InterruptAttack();
        inMeteor = false;
        dashing  = true;
        if (grounded)
        {
            BackwardDust();
        }
        Freeze();
    }
 public void FirstParry()
 {
     AlerterText.Alert("Autoparry active");
     parryParticles.Emit(15);
     Hitstop.Run(0.5f);
     anim.SetTrigger("Parry");
 }
Exemplo n.º 7
0
    void DamageBy(Attack attack)
    {
        if (attack.damage == 0)
        {
            return;
        }

        Instantiate(selfHitmarker, this.transform.position, Quaternion.identity, null);
        SoundManager.PlayerHurtSound();
        currentHP -= attack.GetDamage();

        if (attack.instakill)
        {
            currentHP = 0;
        }

        Hitstop.Run(selfDamageHitstop);

        if (currentHP <= 0)
        {
            Die(attack);
        }
        else if (currentHP > 0 && attack.GetDamage() > 0)
        {
            AlerterText.Alert($"WAVEFORM INTEGRITY {currentHP}");
        }
        else if (currentHP < 4)
        {
            AlerterText.Alert("<color=red>WAVEFORM CRITICAL</color>");
        }
    }
Exemplo n.º 8
0
	public void GainEnergy(int amount) {
		bool notFull = (currentEnergy < maxEnergy);
		currentEnergy += amount;
		if (currentEnergy > maxEnergy) {
			currentEnergy = maxEnergy;
		}
		if (notFull && (currentEnergy == maxEnergy)) AlerterText.Alert("Fully charged");
	}
Exemplo n.º 9
0
 public static void AddItem(InventoryItem item)
 {
     if (!item.IsAbility())
     {
         AlerterText.Alert(item.itemName + " acquired");
     }
     inventory.AddItem(item);
 }
Exemplo n.º 10
0
 public void FirstParry()
 {
     AlerterText.Alert("Autoparry active");
     GetComponent <AnimationInterface>().SpawnFollowingEffect(2);
     anim.SetTrigger("Parry");
     Instantiate(parryParticles, this.transform.position, Quaternion.identity);
     CameraShaker.Shake(0.1f, 0.1f);
     Hitstop.Run(0.5f);
 }
Exemplo n.º 11
0
    void OnTriggerEnter2D(Collider2D other)
    {
        PlayerAttack a = other.GetComponent <PlayerAttack>();

        if (a != null)
        {
            AlerterText.Alert(a.attackName);
        }
    }
Exemplo n.º 12
0
	public override void OnHit(Attack attack) {
		if (dead) {
			return;
		}
		
		CombatMusic.EnterCombat();

		if (!canParry && invincible && !attack.attackerParent.CompareTag(Tags.EnviroDamage)) {
			return;
		}

		bool isEnvDmg = attack.attackerParent.CompareTag(Tags.EnviroDamage);

		if (isEnvDmg) {
			if (envDmgSusceptible) {
				OnEnviroDamage(attack.GetComponent<EnviroDamage>());
				InterruptMeteor();
				if (LayerMask.LayerToName(attack.attackerParent.gameObject.layer) == Layers.Water) {
					RefreshAirMovement();
				}
			}
		} else if (canParry) {
			currentEnergy -= attack.GetDamage();
			if (currentEnergy < 0) {
				AlerterText.Alert("PARRY BREAK");
				Instantiate(shieldBreak, this.transform.position, shieldBreak.transform.rotation, null);
			} else {
				Parry(attack);
				return;
			}
		}

		CameraShaker.Shake(0.2f, 0.1f);
		StartCombatStanceCooldown();
		DamageBy(attack);
		CancelInvoke("StartParryWindow");

		if (this.currentHP == 0) return;
		
		if (isEnvDmg) return;

		StunFor(attack.stunLength);

		// asdi
		float actualSDIMultiplier = sdiMultiplier * (attack.gameObject.CompareTag(Tags.EnviroDamage) ? 0 : 1);
		rb2d.MovePosition(transform.position + ((Vector3) InputManager.MoveVector()*actualSDIMultiplier));

		if (attack.knockBack) {
			Vector2 kv = attack.GetKnockback();
			if (attack.knockbackAway) {
				kv = kv.magnitude * (transform.position - attack.transform.position).normalized; 
			}
			if (!IsFacing(attack.gameObject)) ForceFlip();
			rb2d.velocity = kv;
		}
	}
 void ReturnToSafety()
 {
     AlerterText.Alert("Returning to safety");
     if (this.currentHP <= 0)
     {
         return;
     }
     GlobalController.MovePlayerTo(lastSafeObject.transform.position + (Vector3)lastSafeOffset);
     UnLockInSpace();
 }
Exemplo n.º 14
0
 public static void SaveGame(bool autosave = false)
 {
     if (save.unlocks.HasAbility(Ability.Heal) && !autosave)
     {
         AlerterText.Alert("Rebuilding waveform");
         pc.FullHeal();
         AlerterText.Alert("Done");
     }
     gc.GetComponent <BinarySaver>().SaveGame();
 }
Exemplo n.º 15
0
	public void FirstParry(Attack attack) {
		AlerterText.Alert("Autoparry active");
		anim.SetTrigger("Parry");
		Instantiate(
			diamondShine, 
			GetParryEffectPosition(attack),
			Quaternion.identity,
			null
		);
		Instantiate(parryParticles, this.transform.position, Quaternion.identity);
		CameraShaker.Shake(0.1f, 0.1f);
		Hitstop.Run(0.4f);
	}
Exemplo n.º 16
0
 void AcceptItems()
 {
     if (consumesItems)
     {
         List <InventoryItem> actualWantedItems = wantedItems.Select(x => x.GetItem()).ToList();
         foreach (InventoryItem wantedItem in actualWantedItems)
         {
             AlerterText.Alert(wantedItem.itemName);
             GlobalController.inventory.items.RemoveItem(wantedItem);
         }
     }
     acceptedItemBefore = true;
     UpdateObjectState();
     if (yesActivation != null)
     {
         yesActivation.Activate();
     }
 }
Exemplo n.º 17
0
    IEnumerator ReturnToSafety(float delay)
    {
        yield return(new WaitForSecondsRealtime(delay));

        if (this.currentHP <= 0)
        {
            yield break;
        }
        StunFor(0.2f);
        AlerterText.Alert("Returning to safety");
        if (lastSafeObject != null)
        {
            GlobalController.MovePlayerTo(lastSafeObject.transform.position + (Vector3)lastSafeOffset);
        }
        UnLockInSpace();
        // override invincibility after the teleport so the player doesn't keep taking env damage
        envDmgSusceptible = true;
    }
Exemplo n.º 18
0
    public void StartDashAnimation(bool backwards)
    {
        preDashSpeed = Mathf.Abs(rb2d.velocity.x);
        float additive = 0f;

        // backdash always comes from initial fdash, so subtract fdash speed if necessary
        if (backwards && preDashSpeed > dashSpeed)
        {
            additive = preDashSpeed - dashSpeed;
        }
        float newSpeed = ((backwards ? additive : preDashSpeed) + dashSpeed);

        rb2d.velocity = new Vector2(
            ForwardScalar() * newSpeed,
            Mathf.Max(rb2d.velocity.y, 0)
            );
        if (perfectDashPossible && !earlyDashInput)
        {
            AlerterText.Alert("Recycling boost");
            perfectDashPossible = false;
            CancelInvoke("ClosePerfectDashWindow");
            SoundManager.ShootSound();
        }
        InterruptAttack();
        // if backwards, it'll already have been called
        // don't want a duplicate sound effect
        if (!backwards)
        {
            SoundManager.DashSound();
        }
        inMeteor = false;
        dashing  = true;
        if (grounded)
        {
            BackwardDust();
        }
        Freeze();
        if (dashTimeout != null)
        {
            StopCoroutine(dashTimeout);
        }
        dashTimeout = StartCoroutine(StartDashCooldown(dashCooldownLength));
    }
Exemplo n.º 19
0
 public static void SaveGame(bool autosave = false)
 {
     if (save.unlocks.HasAbility(Ability.Heal) && !autosave)
     {
         AlerterText.Alert("Rebuilding waveform");
         pc.FullHeal();
         AlerterText.Alert("Done");
     }
     save.playerItems      = inventory.items.MakeSerializableInventory();
     save.currentHP        = pc.currentHP;
     save.maxHP            = pc.maxHP;
     save.currentEnergy    = pc.currentEnergy;
     save.maxEnergy        = pc.maxEnergy;
     save.basePlayerDamage = pc.baseDamage;
     save.playerPosition   = pc.transform.position;
     save.sceneName        = SceneManager.GetActiveScene().path;
     gc.GetComponentInChildren <MapFog>().SaveCurrentMap();
     binarySaver.SyncImmediateStates(saveSlot, saveWrapper.save);
     binarySaver.SaveFile(saveWrapper.save, saveSlot);
 }
 public void EndParryWindow()
 {
     canParry   = false;
     parryCount = 0;
     AlerterText.Alert("Autoparry inactive");
 }
Exemplo n.º 21
0
    void LateUpdate()
    {
        if (Input.GetKeyDown(KeyCode.R) && SceneManager.GetActiveScene().name.Equals("TargetTest"))
        {
            SceneManager.LoadScene(SceneManager.GetActiveScene().name);
        }

        if (inAbilityGetUI && InputManager.ButtonDown(Buttons.JUMP))
        {
            HideAbilityGetUI();
        }

        bool inInventory = inventory.inventoryUI.animator.GetBool("Shown");

        if ((InputManager.ButtonDown(Buttons.INVENTORY) || InputManager.GenericEscapeInput()) && inInventory)
        {
            if (inInventory)
            {
                CloseInventory();
            }
        }
        else if (inInventory)
        {
            // avoid any pre-late update weirdness
            pc.EnterCutscene();
        }
        else if (pauseEnabled && InputManager.ButtonDown(Buttons.INVENTORY) && !pc.inCutscene && pc.IsGrounded())
        {
            gc.StartCoroutine(OpenMenu(playerMenu));
        }


        if (InputManager.ButtonDown(Buttons.PAUSE) && pauseEnabled && !inInventory && !paused)
        {
            // pauseUI takes care of unpausing
            Pause();
        }

        if (InputManager.GenericContinueInput())
        {
            GlobalController.OnDialogueSkip();
        }

        dialogueOpenedThisFrame = false;
        dialogueClosedThisFrame = false;

        UpdateControllerStatus();

#if UNITY_EDITOR
        if (Input.GetKeyDown(KeyCode.LeftBracket))
        {
            AlerterText.Alert("Saving game...");
            GlobalController.SaveGame(autosave: false);
            AlerterText.Alert("Game saved");
        }
        else if (Input.GetKeyDown(KeyCode.RightBracket))
        {
            AlerterText.Alert("Loading game...");
            GlobalController.LoadGame();
            AlerterText.Alert("Game loaded");
        }
#endif
    }
Exemplo n.º 22
0
 public void Alert(string alertText)
 {
     AlerterText.Alert(alertText);
 }
Exemplo n.º 23
0
 public static void NewGamePlus()
 {
     AlerterText.Alert("Hey idiot you forgot to make NG+");
     return;
 }
Exemplo n.º 24
0
    public override void OnHit(Attack attack)
    {
        if (dead)
        {
            return;
        }

        if (!canParry && invincible && !attack.attackerParent.CompareTag(Tags.EnviroDamage))
        {
            return;
        }

        if (attack.attackerParent.CompareTag(Tags.EnviroDamage))
        {
            if (envDmgSusceptible)
            {
                OnEnviroDamage(attack.GetComponent <EnviroDamage>());
                InterruptMeteor();
                if (LayerMask.LayerToName(attack.attackerParent.gameObject.layer) == Layers.Water)
                {
                    ResetAirJumps();
                }
            }
        }
        else if (canParry)
        {
            Parry();
            return;
        }

        CameraShaker.Shake(0.2f, 0.1f);
        StartCombatStanceCooldown();
        Hitstop.Run(selfDamageHitstop);
        InterruptSupercruise();
        DamageFor(attack.GetDamage());
        if (currentHP > 0)
        {
            AlerterText.Alert($"WAVEFORM INTEGRITY {currentHP}");
        }
        if (this.currentHP == 0)
        {
            return;
        }
        else if (currentHP == 1)
        {
            AlerterText.Alert("WAVEFORM CRITICAL");
        }
        InvincibleFor(this.invincibilityLength);
        envDmgSusceptible = true;
        StunFor(attack.GetStunLength());
        if (attack.knockBack)
        {
            //knockback based on the position of the attack
            Vector2 kv             = attack.GetKnockback();
            bool    attackerToLeft = attack.transform.position.x < this.transform.position.x;
            kv.x *= attackerToLeft ? 1 : -1;
            KnockBack(kv);
        }
        if (cyan)
        {
            cyan = false;
            StartCoroutine(NormalSprite());
        }
        anim.SetTrigger("Hurt");
    }