IEnumerator doSpawn(float time, BaseCollectible col) { while (running) { yield return new WaitForSeconds(time); Spawn(col); } }
public override void HitCollectible(BaseCollectible collectible) { Player.Collect(collectible); Player.Mood += PlayerSign * collectible.MoodModifier; GameController.Instance.IncreaseTime(collectible.TimeModifier); collectible.Collect(); Player.PlayerSounds.CatchSound(IsFish); }
protected virtual void OnCollisionEnter(Collision collision) { Debug.Log(collision); BaseCollectible collectible = collision.gameObject.GetComponent <BaseCollectible>(); if (collectible != null) { HitCollectible(collectible); } }
protected override void OnCollisionEnter(Collision collision) { Debug.Log(collision); BaseCollectible collectible = collision.gameObject.GetComponent <BaseCollectible>(); if (collectible != null) { float maxSpeed = Mathf.Max(Player.RotationSpeed * 2, Player.MovementSpeed.magnitude * 5f); Vector3 direction = collectible.transform.position - collision.contacts[0].point; direction = direction.normalized * maxSpeed; collectible.Kick(new Vector2(direction.x, direction.y) * KickValue); } }
bool CheckPoint(Vector3 pos) { RaycastHit hit; if (Physics.Raycast(pos + new Vector3(0, 0, -10), new Vector3(0, 0, 1), out hit, 15)) { BaseCollectible collectible = hit.collider.GetComponent <BaseCollectible>(); if (collectible != null) { return(true); } else { return(false); } } else { return(true); } }
protected bool CheckPoint(Vector3 pos) { RaycastHit hit; // Does the ray intersect any objects excluding the player layer if (Physics.Raycast(pos + new Vector3(0, 0, -10), new Vector3(0, 0, 1), out hit, 15)) { PlayerCollidor collectible = hit.collider.GetComponent <PlayerCollidor>(); BaseCollectible col = hit.collider.GetComponent <BaseCollectible>(); if (collectible != null || col == this) { return(true); } else { return(false); } } else { return(true); } }
public void Spawn(BaseCollectible spawn) { float x = Random.Range(0, 1f); float y = Random.Range(0, 1f); x = x * BotLeft.position.x + (1 - x) * TopRight.position.x; y= y * BotLeft.position.y + (1 - y) * TopRight.position.y; int count = 0; while (!spawn.CheckMovement(new Vector3(x,y,0)) && count< maxSpawns) { x = Random.Range(0, 1f); y = Random.Range(0, 1f); x = x * BotLeft.position.x + (1 - x) * TopRight.position.x; y = y * BotLeft.position.y + (1 - y) * TopRight.position.y; count++; } if (count< maxSpawns) { Debug.Log("spawned " + count); Instantiate(spawn, new Vector3(x, y, 0), Quaternion.identity); } else { Debug.Log("No spawn"); } }
public virtual void HitCollectible(BaseCollectible collectible) { }
public void Collect(BaseCollectible collectible) { }