// When it's hit by a player public void PickedUp(Code_Player player) { if (!CheckPlayerForPickUp(player)) { ActivatePickUpEffect(player); } PoolPickUp(); }
// When the shield touches a player it "knocks back the player" public void OnTriggerEnter(Collider col) { Transform colTrans = col.transform; if (col.gameObject != parentPlayer) { if (colTrans.CompareTag(playerTag) || colTrans.CompareTag(shieldTag)) { Code_Player cP = colTrans.GetComponent <Code_Player>(); if (cP != null) { cP.StartKnockback(transform.position); cP.KnockbackSound(); cP.DamageStamina(playerCode.ActualDamage); } } } }
// Stops the gameplay and announces the winner through the VictoryBanner GameObject private void AnnounceWinner(Code_Player winner) { victoryMessageText.text = victoryMessage + GetVictorsColor(winner.playerNumber); victoryBanner.SetActive(true); }
// Overidable function for it's children public virtual void ActivatePickUpEffect(Code_Player player) { print("Activated by player"); // For when a dev made a child but did not override this function }
// Checks if the player already possess the same pickup public virtual bool CheckPlayerForPickUp(Code_Player player) { print("Tell what to do when the player has the same pickup activated already"); // For when a dev made a child but did not override this function // Return a bool based on the results of the check above return(false); // False means that the player does not possess the same pickup effect }
// Checks if the player already possesses has a Teleport public override bool CheckPlayerForPickUp(Code_Player player) { bool canRTP = !player.didTP; return(canRTP); // didTP must be false for true for this function to work, so it'll have to be inversed }
// Gives the player a new Teleport public override void ActivatePickUpEffect(Code_Player player) { player.ResetTelePort(); }
private string shieldTag = "Shield"; // A tag we are looking for when hitting an object, just meant for microoptimisation // Use this for initialization void Start() { anim = GetComponent <Animator>(); myCol = GetComponent <BoxCollider>(); playerCode = parentPlayer.GetComponent <Code_Player>(); }
// Overidable function for it's children public override void ActivatePickUpEffect(Code_Player player) { player.IncreaseStamina(staminaAmount); // For when a dev made a child but did not override this function }
public float staminaAmount; // Amount with which the stamina will be increased by once picked up // Checks if the player already possess the same pickup public override bool CheckPlayerForPickUp(Code_Player player) { return(false); // must always be false because the player itself checks the effect }
// Checks if the player already possess the same pickup public override bool CheckPlayerForPickUp(Code_Player player) { return(player.GetDeathShield()); }
// Gives the player a DeathShield public override void ActivatePickUpEffect(Code_Player player) { player.SetDeathShield(); }
// Use this for initialization void Start() { playerParent = transform.parent.GetComponent <Code_Player>(); }
public float multiplierIncremental; // With how much it has to increase the value of damageMultiplier // Checks if the player already possess the same pickup public override bool CheckPlayerForPickUp(Code_Player player) { return(false); // This must always be false since it does not have to check for anything, the player itself will do this later on }
// Overidable function for it's children public override void ActivatePickUpEffect(Code_Player player) { player.IncreaseDamageMultiplier(multiplierIncremental); }