public void RestartFromCheckpoint()
    {
        myIsPlayerDead = false;
        myOnPlayerRestartCheckpoint?.Invoke();
        myOnResetAtRespawn?.Invoke();
        PickupScript pickup = myCurrentCheckpoint.GetComponent <PickupScript>();

        // Reset player position to my current checkpoint's
        GameObject playerGameObject = GameObject.FindGameObjectWithTag("Player");

        playerGameObject.transform.position = myCurrentCheckpoint.position;
        if (pickup.myRespawnDirection != null && pickup.myRespawnDirection != Vector3.zero) // Look in specified direction
        {
            playerGameObject.transform.LookAt(pickup.transform.position + pickup.myRespawnDirection.normalized * 5f);
        }
        else
        {
            playerGameObject.transform.LookAt(pickup.myNextTarget.transform.position); // Default to next target
        }

        pickup.myNextTarget.ActivateMeAsTarget();

        var planeController = playerGameObject.GetComponent <PlaneController>();

        planeController.myCurrentVelocity = planeController.myStartingVelocity;
        playerGameObject.GetComponent <Fuel>().enabled = false;
        playerGameObject.GetComponent <Fuel>().SetFuelToMax();

        myOnAfterPlayerRestartCheckpoint?.Invoke();
    }
Exemple #2
0
    void AddItem(PickupScript a)
    {
        InventoryItem temp = new InventoryItem(a.count, a.useRate, a.effectValue);

        totalInventory.AddLast(temp);
        inventoryCount++;
    }
Exemple #3
0
    //Changes the color of this gameobject based on the index of the given object.
    //Also adds the given gameobject to the list of "Orbs" to track mixed in objects.
    public void Mix(GameObject otherOne)
    {
        PickupScript other = otherOne.GetComponent <PickupScript>();

        if ((index == 0 && other.Index == 2) || (index == 2 && other.Index == 0))
        {
            ChangeColor(1);
            otherOrbs.Add(otherOne);
        }
        else if ((index == 0 && other.Index == 4) || (index == 4 && other.Index == 0))
        {
            ChangeColor(5);
            otherOrbs.Add(otherOne);
        }
        else if ((index == 2 && other.Index == 4) || (index == 4 && other.Index == 2))
        {
            ChangeColor(3);
            otherOrbs.Add(otherOne);
        }
        else if ((index == 1 && other.Index == 4) || (index == 4 && other.Index == 1) || (index == 0 && other.Index == 3) || (index == 3 && other.Index == 0) || (index == 5 && other.Index == 2) || (index == 2 && other.Index == 5))
        {
            ChangeColor(6);
            otherOrbs.Add(otherOne);
        }
        else
        {
            throw new System.Exception();
        }
    }
Exemple #4
0
 //Checks to see if this gameobject and another given gameobject can mix and returns the corresponding boolean. True if they can mix and false if they can't.
 public bool CanMix(PickupScript other)
 {
     if ((index == 0 && other.Index == 2) || (index == 2 && other.Index == 0) || (index == 0 && other.Index == 4) || (index == 4 && other.Index == 0) || (index == 2 && other.Index == 4) || (index == 4 && other.Index == 2) || (index == 1 && other.Index == 4) || (index == 4 && other.Index == 1) || (index == 0 && other.Index == 3) || (index == 3 && other.Index == 0) || (index == 5 && other.Index == 2) || (index == 2 && other.Index == 5))
     {
         return(true);
     }
     return(false);
 }
Exemple #5
0
 // Start is called before the first frame update
 void Start()
 {
     player        = GameObject.FindGameObjectWithTag("Player");
     ps            = player.GetComponent <PickupScript>();
     score         = 0;
     corpseCounter = spawnRate;
     SpawnCorpse();
 }
Exemple #6
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(this);
     }
     rend = gameObject.GetComponent <Renderer>();
     rend.material.color = new Color(UnityEngine.Random.value, UnityEngine.Random.value, UnityEngine.Random.value);
     startCollection     = Collect;
 }
Exemple #7
0
    void OnTriggerEnter(Collider collision)
    {
        print("Mouse trigger" + collision.gameObject.name);
        GameObject collideObject = collision.gameObject;

        if (collideObject.tag == "Platform" && inventory != null)
        {
            if (inventory == collideObject.GetComponent <PickUpPlatformScript>().color)
            {
                print("Dropoff Color " + collideObject.GetComponent <PickUpPlatformScript>().color);
                inventory = null;
                heldItem  = null;

                collideObject.GetComponent <PickUpPlatformScript>().toggleActive();
                stopParticleEffect();
                gameObject.GetComponent <MovementScript>().speed = 5;
            }
        }
        if (collideObject.layer == gmScript.pickupLayer)
        {
            print("It's Cheese!");
            if (inventory == null)
            {
                print("Pick it up!");
                source.Play();
                PickupScript pickupScript = collideObject.GetComponent <PickupScript>();
                inventory = pickupScript.color;
                heldItem  = collideObject;

                startParticleEffect(pickupScript.color);
                gameObject.GetComponent <MovementScript>().speed = 4.8f;

                var newPosition = collideObject.transform.position;
                newPosition.y = newPosition.y - 2;
                collideObject.transform.position = newPosition;
            }
        }
    }
Exemple #8
0
    void OnTriggerStay(Collider other)
    {
        NpcScript npcIdentifier = other.GetComponent<NpcScript> ();

        //call universal triggers here, don't put level-specific ones, probably best to create a seperate script for that (Aidan 11/10/15)
        if (other.tag == "NPC" || other.tag == "NPC_MotherBear")
        {
        //			Debug.Log ("NPC detected you");
            NewChatScript chatCheckScript = other.GetComponent<NewChatScript>();
        //			Debug.Log(chatCheckScript.chatEnabled);
            currentlyInChat = chatCheckScript.chatEnabled;
        }

        if (other.tag == "Tree")
        {
            Debug.Log(other.tag);
            return;
        }
        #region TestingArea2
        if (other.tag == "pickup" && testMode) {
            pickupScript = other.GetComponent<PickupScript>();
            Debug.Log (other.tag);

            if (Input.GetKeyDown(KeyCode.E))
            {
                lastHeldItem = currentHeldItem;
                pickupScript.SpriteUpdate();
            currentHeldItem = pickupScript.itemSecondaryTag; //Gets the secondary tag name from item you have just collided with, in case it is tagged as pick up /H

                PickupScript itemHeld = GetComponentInChildren<PickupScript>();
                itemHeld.spriteRenderer.enabled = true;
            }

        }

        #endregion
    }
    public void SpawnPickup(Vector3 pos, PickupScript.PickupType type = PickupScript.PickupType.None)
    {
        GameObject instance;

		if(type == PickupScript.PickupType.None)
		{
			type = GetRandomPickup();
		}

        switch (type)
        {
            case PickupScript.PickupType.Machinegun:
                instance = Instantiate(machinegunPrefab);
                break;
            case PickupScript.PickupType.Rocketlauncher:
                instance = Instantiate(rocketlauncherPrefab);
                break;
            case PickupScript.PickupType.Ammo:
                instance = Instantiate(ammoPrefab);
                break;
            case PickupScript.PickupType.HeatDispertion:
                instance = Instantiate(heatDispersorPrefab);
                break;
            case PickupScript.PickupType.Speed:
                instance = Instantiate(speedPrefab);
                break;
            case PickupScript.PickupType.Nuke:
                instance = Instantiate(nukePrefab);
                break;
            default:
				return;
        }

        instance.transform.parent = _planet.transform;
        instance.transform.position = pos;
    }
Exemple #10
0
    void Start()
    {
        currentHeldItem = "nothingHeld";
        spriteRenderer = GetComponent<SpriteRenderer> ();

        facingDir = FacingDirection.Right;
        controller = GetComponent<CharacterController>();
        pickupScript = GetComponent<PickupScript>();
        myTrans = transform;
    }
Exemple #11
0
 void Start()
 {
     pickupscript = GameObject.Find("Player").GetComponent <PickupScript>();
 }
Exemple #12
0
 public void CollectPickup(PickupScript pickUp)
 {
     pickupDictionary[pickUp.type] = pickupDictionary[pickUp.type] + 1;
 }
Exemple #13
0
    private void GainPickup(PickupScript pickupInfo)
    {
        switch (pickupInfo.CurrentPickupType)
        {
            case PickupScript.PickupType.Spread:
                currentAction = PlayerAction.Throw_Spread;
                break;
            case PickupScript.PickupType.Boomerang:
                currentAction = PlayerAction.Throw_Boomerang;
                break;
            case PickupScript.PickupType.Enlarge:
                currentAction = PlayerAction.Throw_Enlarge;
                break;
            case PickupScript.PickupType.Homing:
                currentAction = PlayerAction.Throw_Homing;
                break;
        }
        //Spawn the pickup text
        GameObject pickupText = GameObject.Instantiate(Resources.Load("Prefabs/GUI/PickupAlert"), pickupInfo.gameObject.transform.position,
                                                       pickupInfo.gameObject.transform.rotation) as GameObject;
        pickupText.GetComponent<PickupAlertScript>().PickupText(pickupInfo.CurrentPickupType.ToString() );

        Destroy(pickupInfo.gameObject);
    }
Exemple #14
0
 // Start is called before the first frame update
 void Start()
 {
     gm = GameObject.FindGameObjectWithTag("GameManager").GetComponent <GameManager>();
     ps = GameObject.FindGameObjectWithTag("Player").GetComponent <PickupScript>();
 }
 void Start()
 {
     Animcloud    = GetComponent <Animator>();
     pickupscript = GameObject.Find("Player").GetComponent <PickupScript>();
 }