Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
2.5 kB
1
Indexable
Never
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PickupManager : MonoBehaviour
{
    
    private LaneManager lane;
    PlayerMovement pMov;
    ShieldMessage shieldMessage;
    RoadScroll scroll;

    public bool LaneSpeedIncrease = false;
    public bool LaneSpeedReset = false;
    public bool increaseTraffic = false;

    GameObject CoinDetector;
    public bool canAttract = false;



    void Start()
    {
       scroll = FindObjectOfType<RoadScroll>();
       shieldMessage = FindObjectOfType<ShieldMessage>();
       pMov = FindObjectOfType<PlayerMovement>();
       lane = FindObjectOfType<LaneManager>();
        if (lane == null)
        {
            Debug.LogError("LaneManager component not found!");
        }

        increaseTraffic = false;

        CoinDetector = GameObject.FindGameObjectWithTag("CoinDetector");
        CoinDetector.SetActive(false);
    }

  
    void Update()
    {
        
    }

   

    public void SelectLaneIncrease()
    {
        if (lane != null)
        {
            if (lane.LaneCount < 6)
            {
                lane.LaneIncrease();

            }
            else
            {
               
                return;
            }
        }
        
    }

    public void SelectLaneDecrease()
    {
        if (lane != null)
        {
            if (lane.LaneCount > 2)
            {
                lane.LaneDecrease();

            }
            else
            {
               
                return;
            }
        }
        
    }

    public void SelectDefense()
    {
        pMov.hasShield = true;
        shieldMessage.ShowMessage();
    }

    public void SelectLaneSpeedIncrease()
    {
        LaneSpeedIncrease = true;
        LaneSpeedReset = false;

       
    }

    public void SelectLaneSpeedDecrease()
    {
        LaneSpeedReset = true;
        LaneSpeedIncrease = false;

        
    }

    public void SelectTraffic()
    {
        increaseTraffic = true;
        Debug.Log("Traffic INCREASED");
    }

    public void SelectMagnet()
    {
        StartCoroutine(Magnetism());
    }

    public IEnumerator Magnetism()
    {
        canAttract = true;
        CoinDetector.SetActive(true);
        yield return new WaitForSeconds(10f);
        CoinDetector.SetActive(false);
        canAttract = false;
    }

}
Leave a Comment