Example #1
0
    IEnumerator doSpawn(float time, BaseCollectible col) {
        while (running) {

            yield return new WaitForSeconds(time);
            Spawn(col);
        }
    }
Example #2
0
 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);
 }
Example #3
0
    protected virtual void OnCollisionEnter(Collision collision)
    {
        Debug.Log(collision);
        BaseCollectible collectible = collision.gameObject.GetComponent <BaseCollectible>();

        if (collectible != null)
        {
            HitCollectible(collectible);
        }
    }
Example #4
0
    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);
        }
    }
Example #5
0
    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);
        }
    }
Example #6
0
    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);
        }
    }
Example #7
0
    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");
        }

    }
Example #8
0
 public virtual void HitCollectible(BaseCollectible collectible)
 {
 }
Example #9
0
 public void Collect(BaseCollectible collectible)
 {
 }