Inheritance: MonoBehaviour
Esempio n. 1
0
 void Start()
 {
     isPaused = false;
     pc       = Player.GetComponent <PlayerController>();
     ts       = Player.GetComponent <TorchScript>();
     fs       = FearPanel.GetComponent <Fear>();
 }
Esempio n. 2
0
    // Use this for initialization
    void Start()
    {
        player = GameObject.FindObjectOfType <Player>();
        eyes   = GetComponentInChildren <Camera>();
        torch  = GameObject.FindObjectOfType <TorchScript>();


        heli  = GameObject.FindObjectOfType <Heli>();
        radio = GameObject.FindObjectOfType <Radio>();
    }
Esempio n. 3
0
    void Update()
    {
        TorchScript  saveDataTorch = saveTorch.GetComponent <TorchScript>();
        SpeedrunTime timer         = time.GetComponent <SpeedrunTime>();
        keyPickup    keyCounter    = key.GetComponent <keyPickup>();

        textCounterCoins.text = coins.ToString();
        if (chest.isChanged == 0)
        {
            textCounterPotion.text = potions.ToString();
        }
        else if (chest.isChanged == 1 && which.whichOne == 0)
        {
            textCounterPotion.text = potion_mvspeed.ToString();
        }
        else if (chest.isChanged == 1 && which.whichOne == 1)
        {
            textCounterPotion.text = potion_invisible.ToString();
        }
        textCounterTrap.text  = trap.ToString();
        textCounterTorch.text = torches.ToString();
        textCounterKeys.text  = keyCounter.key.ToString();

        movement.x = Input.GetAxisRaw("Horizontal");
        movement.y = Input.GetAxisRaw("Vertical");
        movement   = movement.normalized;
        hf         = movement.x > 0.01f ? movement.x : movement.x < -0.01f ? 1 : 0;
        speed      = movement.y > 0.01f ? movement.y : movement.y < -0.01f ? 1 : 0;
        if (movement.x < -0.01f)
        {
            this.gameObject.transform.localScale = new Vector3(-1, 1, 1);
        }
        else
        {
            this.gameObject.transform.localScale = new Vector3(1, 1, 1);
        }


        anim.SetFloat("Horizontal", hf);
        anim.SetFloat("Vertical", movement.y);
        anim.SetFloat("Speed", speed);
    }
Esempio n. 4
0
    //Performs interaction with gameObject based on its tag
    //Executed when player is near interactables and presses "E"
    void Interact(GameObject interactable)
    {
        if (interactable != null)
        {
            //If interactable is a torch, check that we have enough light to activate it and that it is not already lit
            //If all conditions are met, light the torch, reduce lightAmt by cost
            if (interactable.CompareTag("Torch"))
            {
                TorchScript tScript = interactable.GetComponent <TorchScript>();
                if (tScript != null)
                {
                    if (lightAmt > torchCost && !tScript.lit)
                    {
                        tScript.LightTorch();
                        lightAmt -= torchCost;
                    }
                }
            }

            else if (interactable.CompareTag("Campfire"))
            {
                CampfireScript cScript = interactable.GetComponent <CampfireScript>();
                if (cScript != null)
                {
                    if (lightAmt > torchCost && cScript.isLit == false)
                    {
                        cScript.LightCampfire();
                        lightAmt -= torchCost;
                    }
                    else if (lightAmt > torchCost && cScript.isLit == true)
                    {
                        lightAmt             = (lightAmt + cScript.campLightAmt) / 2;
                        cScript.campLightAmt = (lightAmt + cScript.campLightAmt) / 2;
                    }
                }
            }

            //If interactable is a source, give player light from the source and destroy it
            else if (interactable.CompareTag("Source"))
            {
                SourceScript sScript = interactable.GetComponent <SourceScript>();
                if (sScript != null)
                {
                    lightAmt += sScript.lightStored;
                    Destroy(interactable);
                }
            }


            else if (interactable.CompareTag("Bomb"))
            {
                Bomb bomb = interactable.GetComponent <Bomb>();
                if (bomb != null)
                {
                    bomb.Ignite();
                }
            }

            else if (interactable.CompareTag("Zipline"))
            {
                Zipline zScript = interactable.GetComponentInParent <Zipline>();
                if (zScript != null)
                {
                    if (lightAmt > ziplineCost && !zScript.isActive)
                    {
                        zScript.Activate();
                        lightAmt -= ziplineCost;
                    }
                    else
                    {
                        if (zScript.isActive)
                        {
                            Vector3 startAnchor = interactable.transform.position;
                            Vector3 endAnchor;
                            if (interactable.transform == zScript.AnchorA)
                            {
                                endAnchor = zScript.AnchorB.position;
                            }
                            else
                            {
                                endAnchor = zScript.AnchorA.position;
                            }
                            StartCoroutine(UseZipline(startAnchor, endAnchor));
                        }
                    }
                }
            }
        }
    }
 // Start is called before the first frame update
 void Start()
 {
     ts       = GetComponent <TorchScript>();
     animator = GetComponent <Animator>();
     sr       = GetComponent <SpriteRenderer>();
 }
 void Start()
 {
     torch = GameObject.FindGameObjectWithTag("torchobject").GetComponent <TorchScript>();
 }
Esempio n. 7
0
 // Use this for initialization
 void Start()
 {
     t  = GetComponent <TorchScript>();
     l1 = transform.GetChild(0).gameObject;
     l2 = transform.GetChild(1).gameObject;
 }