Exemple #1
0
    // Function for moving the player with the Poseidon trap.
    // For best use, arrowKeysEnabled should be set to false.
    // Can be cleaned up with a seperate function for each of these movements.
    IEnumerator findPoseidonDirection(TrapInteraction TrapScript)
    {
        // Wait while the poseidon trap is configuring its rotation.
        while (TrapScript.poseidonDirectionReady == false)
        {
            yield return(null);
        }
        // Get the direction 0 to 3, which indicates how many times the
        // trap has been rotates by 90 degrees.
        int direction = TrapScript.poseidonDirection;

        Debug.Log("The direction of Poseidon is: " + direction);
        // If the poseidon direction is up, move the player up.
        if (direction == 0)
        {
            //	    rb.MovePosition(rb.position + new Vector2(0,1));
            //	    this.movePlayer(new Vector3(0,1,0));
            ClientSend.PlayerMovement(new bool[] { true, false, false, false });
            //ani.SetFloat("up", 1f);
            //yield return new WaitForSeconds(0.1f);
            //ani.SetFloat("up", 0f);
            //setAllAnimatorZero();
        }
        // If the poseidon direction is right, move the player right.
        else if (direction == 1)
        {
            //	    rb.MovePosition(rb.position + new Vector2(-1,0));
            //this.movePlayer(new Vector3(-1,0,0));
            ClientSend.PlayerMovement(new bool[] { false, false, true, false });
            //ani.SetFloat("right", 1f);
            //ani.SetFloat("FacingLeft", 0f);
            //yield return new WaitForSeconds(0.1f);
            //ani.SetFloat("right", 0f);
            //setAllAnimatorZero();
        }
        // If the poseidon direction is down, move the player down.
        else if (direction == 2)
        {
            //	    rb.MovePosition(rb.position + new Vector2(0,-1));
            //this.movePlayer(new Vector3(0,-1,0));
            ClientSend.PlayerMovement(new bool[] { false, true, false, false });
            //ani.SetFloat("down", 1f);
            //yield return new WaitForSeconds(0.1f);
            //ani.SetFloat("down", 0f);
            //setAllAnimatorZero();
        }
        // If the poseidon direction is left, move the player left.
        else
        {
            //rb.MovePosition(rb.position + new Vector2(1,0));
            //this.movePlayer(new Vector3(1,0,0));
            ClientSend.PlayerMovement(new bool[] { false, false, false, true });
            //ani.SetFloat("left", 1f);
            //ani.SetFloat("FacingLeft", 1f);
            //yield return new WaitForSeconds(0.1f);
            //ani.SetFloat("left", 0f);
            //setAllAnimatorZero();
        }
        //yield return 0;
    }
Exemple #2
0
    // Use this for initialization
    void Start()
    {
        rBody = GetComponent <Rigidbody>();

        gm = GameManager.Instance;
        //get input manager and captains
        switch (playerNum)
        {
        case 1:
            captain      = gm.PirateP1.gameObject;
            itemSlot     = GameObject.FindGameObjectWithTag("ItemSlot1");
            inputManager = gm.P1Input;
            break;

        case 2:
            captain      = gm.PirateP2.gameObject;
            itemSlot     = GameObject.FindGameObjectWithTag("ItemSlot2");
            inputManager = gm.P2Input;
            break;
        }

        ReturnToSpawn(gm.ParrotSpawn.transform.position);

        //pickupScript = GetComponent<ItemPickup>(); //Get the item pickup script
        trapScript     = GetComponent <TrapInteraction>(); //Get the trap interaction script
        currentUtility = utilityItems[0];                  // assign initial utility
        dropCooldown   = utilityCooldowns[0];              // assign initial utility
        SpawnUtility();

        buttonHeldOnEntry = 0;

        currentSpeed = baseSpeed;
    }
Exemple #3
0
    // Function for moving the player with the Poseidon trap.
    // For best use, arrowKeysEnabled should be set to false.
    // Can be cleaned up with a seperate function for each of these movements.
    IEnumerator findPoseidonDirection(TrapInteraction TrapScript)
    {
        // Wait while the poseidon trap is configuring its rotation.
        while (TrapScript.poseidonDirectionReady == false)
        {
            yield return(null);
        }

        // Get the direction 0 to 3, which indicates how many times the
        // trap has been rotates by 90 degrees.
        int direction = TrapScript.poseidonDirection;

        Debug.Log("The direction of Poseidon is: " + direction);

        // If the poseidon direction is up, move the player up.
        if (direction == 0)
        {
            rb.MovePosition(rb.position + new Vector2(0, 1));
            ani.SetFloat("up", 1f);
            yield return(new WaitForSeconds(0.1f));

            ani.SetFloat("up", 0f);
        }
        // If the poseidon direction is right, move the player right.
        else if (direction == 1)
        {
            rb.MovePosition(rb.position + new Vector2(-1, 0));
            ani.SetFloat("right", 1f);
            ani.SetFloat("FacingLeft", 0f);
            yield return(new WaitForSeconds(0.1f));

            ani.SetFloat("right", 0f);
        }
        // If the poseidon direction is down, move the player down.
        else if (direction == 2)
        {
            rb.MovePosition(rb.position + new Vector2(0, -1));
            ani.SetFloat("down", 1f);
            yield return(new WaitForSeconds(0.1f));

            ani.SetFloat("down", 0f);
        }
        // If the poseidon direction is left, move the player left.
        else
        {
            rb.MovePosition(rb.position + new Vector2(1, 0));
            ani.SetFloat("left", 1f);
            ani.SetFloat("FacingLeft", 1f);
            yield return(new WaitForSeconds(0.1f));

            ani.SetFloat("left", 0f);
        }

        yield return(0);
    }
Exemple #4
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.name == "Hole" && flying == false)
        {
            //	    Debug.Log("OnCollisionEnter2D TRIGGER");
            arrowKeysEnabled = false;
            pm.isAlive       = false;
            StartCoroutine(HoleDeath());
        }
        // Deals with trap interaction. (e.g. kills character if they stand on a trap)
        else if (other.GetComponent <TrapInteraction>() != null && flying == false)
        {
            arrowKeysEnabled = false;
            TrapInteraction TrapScript = other.GetComponent <TrapInteraction>();
            string          name       = TrapScript.trap.trapName;
            if (name == "PoseidonTrap")
            {
                StartCoroutine(findPoseidonDirection(TrapScript));
            }
            else if (name == "HadesTrap")
            {
                Debug.Log("Death by Hades!");
                StartCoroutine(HadesDeath());
                pm.isAlive = false;
                //FindObjectOfType<GameManager>().EndGame();
            }
            else if (name == "FireTrap")
            {
                StartCoroutine(FireTrap());
                pm.isAlive = false;
                Debug.Log("Death by Fire!");
            }
            else if (name == "SpikeTrap")
            {
                pm.isAlive = false;
                StartCoroutine(spikeTrap());
                Debug.Log("Death by Spike!");
            }
            else if (name == "ZeusMainTrap")
            {
                Debug.Log("Death by Zeus!");
                pm.isAlive = false;
                StartCoroutine(ZeusDeath());
                //FindObjectOfType<GameManager>().EndGame();
            }
        }
        // Deals with Zeus' diagonal bolts of lightning.
        else if (other.GetComponent <ZeusDiagonal>() != null && flying == false)
        {
            Debug.Log("Death by Zeus Diagonal!");
            pm.isAlive = false;
            StartCoroutine(ZeusDiagonalDeath());
            FindObjectOfType <GameManager>().EndGame();
        }
        // Deals with pickup interaction. (e.g. the Hermes status effect)
        else if (other.GetComponent <WildFire>() != null && flying == false)
        {
            Debug.Log("Death by WildFire!");
            pm.isAlive = false;
            StartCoroutine(FireTrap());
            //FindObjectOfType<GameManager>().EndGame();
        }

        else if (other.GetComponent <Pickup>() != null)
        {
            Pickup PickupScript = other.GetComponent <Pickup>();
            string name         = PickupScript.trap.trapName;
            if (name == "HermesPickup")
            {
                Debug.Log("Red Bull gives you Wiiings");
                ani.SetBool("Flying", true);
                flying = true;
            }
        }
        Inventory_Item item = other.GetComponent <Inventory_Item>();

        if (item != null)
        {
            inventory.AddItem(item);
        }
    }