示例#1
0
    void GetStuck(Vector3 stuckPos, Vector3 scale, int stickyID)
    {
        Debug.Log("Got stuck");
        isStuck       = true;
        stuckPosition = stuckPos;

        StickyBomb[] stickys   = GameObject.FindObjectsOfType <StickyBomb> ();
        StickyBomb   theSticky = null;

        foreach (var s in stickys)
        {
            if (s.GetComponent <PhotonView>().viewID == stickyID)
            {
                theSticky = s;
                break;
            }
        }

        if (theSticky != null)
        {
            AudioSource.PlayClipAtPoint(getStuck, GameObject.FindObjectOfType <GameCamera>().transform.position);
            currentStuck = theSticky.GetComponent <StickyBomb>();
            theSticky.transform.SetParent(this.transform);
            theSticky.transform.localScale = scale * 9;
            theSticky.transform.position   = stuckPos;
            theSticky.GetComponent <Rigidbody2D>().isKinematic = true;
            theSticky.isStuck = true;
            theSticky.GetComponent <StickyBomb>().stuckID = playerID;
            PopText.Create("STUCK!", Color.white, 120, this.transform.position + Vector3.up * .5f);
            Debug.Log("Current stuck: " + currentStuck.name);
        }
    }
示例#2
0
    void LocalLogic(Collider2D c)
    {
        PlayerController pc = this.transform.root.GetComponent <PlayerController>();
        StickyBomb       sb = c.gameObject.GetComponent <StickyBomb>();

        Debug.Log("Sticky : " + sb.ownerID + ", Owner: " + pc.playerID);

        if (sb.hitGround)
        {
            PopText.Create("Get Bomb!", Color.black, 60, sb.transform.position + Vector3.up);
            Vector3 scale = new Vector3(c.gameObject.transform.localScale.x, c.gameObject.transform.localScale.y, c.gameObject.transform.localScale.z);
            pc.LOCAL_PickupBombGround(sb);
        }
        else
        {
            if (!pc.playerID.Equals(sb.ownerID) && !sb.isStuck)
            {
                Debug.Log("Sucess!");
                Vector3 scale = new Vector3(c.gameObject.transform.localScale.x, c.gameObject.transform.localScale.y, c.gameObject.transform.localScale.z);
                pc.LOCAL_GetStuck(sb.transform.position, scale, sb);
            }

            //for switching owners
            else if (sb.isStuck && !sb.GetComponent <LocalStickyBomb>().justTransfered&&
                     !pc.playerID.Equals(sb.stuckID))
            {
                Debug.Log("Sucess!");
                Vector3 scale = new Vector3(c.gameObject.transform.localScale.x, c.gameObject.transform.localScale.y, c.gameObject.transform.localScale.z);
                //this transform, scale, stickyID
                pc.LOCAL_SwitchOwners(sb.transform.position, scale, sb);
                sb.GetComponent <LocalStickyBomb>().TransferBomb();
            }
        }
    }
示例#3
0
    public void LOCAL_SwitchOwners(Vector3 stuckPos, Vector3 scale, StickyBomb theSticky)
    {
        isStuck       = true;
        stuckPosition = stuckPos;

        if (theSticky != null)
        {
            currentStuck = theSticky.GetComponent <StickyBomb>();
            theSticky.transform.SetParent(this.transform);
            theSticky.transform.position = stuckPos;
            theSticky.GetComponent <Rigidbody2D>().isKinematic = true;
            theSticky.isStuck = true;
            //the person that ran into you is now the potential killer
            theSticky.GetComponent <StickyBomb>().ownerID = theSticky.GetComponent <StickyBomb>().stuckID;
            theSticky.GetComponent <StickyBomb>().stuckID = playerID;
            theSticky.GetComponent <LocalStickyBomb>().TransferBomb();
            PopText.Create("STUCK!", Color.white, 120, this.transform.position + Vector3.up * .5f);
            //get the new owner and tell him he isnt stuck anymore
            AudioSource.PlayClipAtPoint(transferBomb, GameObject.FindObjectOfType <GameCamera>().transform.position);
            PlayerController   newOwner = null;
            PlayerController[] players  = GameObject.FindObjectsOfType <PlayerController>();

            foreach (var p in players)
            {
                if (p.playerID == theSticky.ownerID)
                {
                    newOwner = p;
                }
            }

            newOwner.isStuck      = false;
            newOwner.currentStuck = null;
        }
        GameObject.Find("Main Camera").GetComponent <GameCamera> ().BombStuck();
    }
示例#4
0
    public void LOCAL_GetStuck(Vector3 stuckPos, Vector3 scale, StickyBomb theSticky)
    {
        isStuck       = true;
        stuckPosition = stuckPos;

        if (theSticky != null)
        {
            if (!isPaused)
            {
                theSticky.GetComponent <LocalStickyBomb> ().gamePaused = false;
                AudioSource.PlayClipAtPoint(getStuck, GameObject.FindObjectOfType <GameCamera> ().transform.position);
                currentStuck = theSticky.GetComponent <StickyBomb> ();
                theSticky.transform.SetParent(this.transform);
                theSticky.transform.localScale = scale * 9;
                theSticky.transform.position   = stuckPos;
                theSticky.GetComponent <Rigidbody2D> ().isKinematic = true;
                theSticky.isStuck = true;
                theSticky.GetComponent <LocalStickyBomb> ().TransferBomb();
                theSticky.GetComponent <StickyBomb> ().stuckID = playerID;
                PopText.Create("STUCK!", Color.white, 120, this.transform.position + Vector3.up * .5f);
                Debug.Log("Current stuck: " + currentStuck.name);
            }
            else
            {
                theSticky.GetComponent <LocalStickyBomb> ().gamePaused = true;
            }
        }
    }
示例#5
0
    void NetworkedLogic(Collider2D c)
    {
        PlayerController pc = this.transform.root.GetComponent <PlayerController>();
        StickyBomb       sb = c.gameObject.GetComponent <StickyBomb>();

        Debug.Log("Sticky : " + sb.ownerID + ", Owner: " + pc.playerID);

        if (sb.hitGround)
        {
            PopText.Create("Get Bomb!", Color.black, 60, sb.transform.position + Vector3.up);
            Vector3 scale = new Vector3(c.gameObject.transform.localScale.x, c.gameObject.transform.localScale.y, c.gameObject.transform.localScale.z);
            //this transform, scale, stickyID
            pc.GetComponent <PhotonView> ().RPC("PickupBombGround", PhotonTargets.All, sb.transform.position, scale, sb.GetComponent <PhotonView>().viewID);
        }
        else
        {
            if (!pc.playerID.Equals(sb.ownerID) && !sb.isStuck)
            {
                Debug.Log("Sucess!");
                Vector3 scale = new Vector3(c.gameObject.transform.localScale.x, c.gameObject.transform.localScale.y, c.gameObject.transform.localScale.z);
                //this transform, scale, stickyID
                pc.GetComponent <PhotonView> ().RPC("GetStuck", PhotonTargets.All, sb.transform.position, scale, sb.GetComponent <PhotonView>().viewID);
            }

            //for switching owners
            else if (sb.isStuck && !sb.GetComponent <NetworkStickyBomb>().justTransfered&&
                     !pc.playerID.Equals(sb.stuckID))
            {
                Debug.Log("Sucess!");
                Vector3 scale = new Vector3(c.gameObject.transform.localScale.x, c.gameObject.transform.localScale.y, c.gameObject.transform.localScale.z);
                //this transform, scale, stickyID
                pc.GetComponent <PhotonView> ().RPC("SwitchOwners", PhotonTargets.All, sb.transform.position, sb.GetComponent <PhotonView>().viewID);

                //call first on master client so transfer doesnt occur multiple times
                sb.GetComponent <NetworkStickyBomb>().TransferBomb();
            }
        }
    }
示例#6
0
    void SetBomb(int stickyID, string pName)
    {
        StickyBomb[] stickys   = GameObject.FindObjectsOfType <StickyBomb> ();
        StickyBomb   theSticky = null;

        foreach (var s in stickys)
        {
            if (s.GetComponent <PhotonView>().viewID == stickyID)
            {
                theSticky = s;
                break;
            }
        }
        theSticky.GetComponent <StickyBomb>().ownerID = playerID;
    }