Пример #1
0
    public override void OnRead(NetDataReader reader, bool initialState)
    {
        if (isOwner)
        {
            reader.GetInt();
            reader.GetInt();
            reader.GetVector3();
            reader.GetVector2();
            reader.GetBool();
            reader.GetBool();
            reader.GetBool();
            return;
        }

        int pickedUpObject = reader.GetInt();

        if (pickedUpObject >= 0)
        {
            RPCPickup(pickedUpObject);
        }
        else if (PickedUpObject)
        {
            PickedUpObject.RPCDrop();
            PickedUpObject = null;
        }


        State           = (STATE)reader.GetInt();
        Direction       = reader.GetVector3();
        CurrentVelocity = reader.GetVector2();
        HasThrown       = reader.GetBool();
        CanBeTackled    = reader.GetBool();
        if (!Animations)
        {
            Animations = gameObject.GetComponent <Chadimations>();
        }
        Animations.Throwing = reader.GetBool();
    }
Пример #2
0
    void OnTriggerEnter(Collider other)
    {
        PickupableObject po = other.GetComponent <PickupableObject>();

        if (po.pickupObject != null)
        {
            PickupController pc = po.pickupObject.parent.parent.GetComponent <PickupController> ();
            if (pc != null)
            {
                pc.CmdDrop(other.gameObject);
            }
        }

        if (gameObject.tag == "Fish")
        {
            if (other.name == "Fox")
            {
                other.tag = "InterObj";
                //other.transform.parent = transform;
                other.transform.position      = foxTarPos.transform.position;
                other.transform.localRotation = Quaternion.identity;
                if (!inside.Contains(other.gameObject))
                {
                    inside.Add(other.gameObject);
                }
                //foxPlaced = true;
            }
            if (other.name == "Hen")
            {
                other.tag = "InterObj";
                //other.transform.parent = transform;
                other.transform.position      = henTarPos.transform.position;
                other.transform.localRotation = Quaternion.identity;
                if (!inside.Contains(other.gameObject))
                {
                    inside.Add(other.gameObject);
                }
            }
            if (other.name == "Grain")
            {
                other.tag = "InterObj";
                //other.transform.parent = transform;
                other.transform.position      = grainTarPos.transform.position;
                other.transform.localRotation = Quaternion.identity;
                if (!inside.Contains(other.gameObject))
                {
                    inside.Add(other.gameObject);
                }
            }

            if (transform.childCount == 3)
            {
                print("Door open");
                Destroy(checker);
                //winImage.SetActive(true);



                foxObj.GetComponent <SphereCollider> ().enabled   = false;
                henObj.GetComponent <SphereCollider> ().enabled   = false;
                grainObj.GetComponent <SphereCollider> ().enabled = false;
            }
        }
        else
        {
            if (other.name == "Fox")
            {
                other.tag = "InterObj";
                //other.transform.parent = transform;
                other.transform.position = foxStartPos.transform.position;
                other.transform.rotation = Quaternion.Euler(0f, 0f, 0f);
                if (!inside.Contains(other.gameObject))
                {
                    inside.Add(other.gameObject);
                }
            }

            if (other.name == "Hen")
            {
                other.tag = "InterObj";
                //other.transform.parent = transform;
                other.transform.position = henStartPos.transform.position;
                other.transform.rotation = Quaternion.Euler(0f, 0f, 0f);
                if (!inside.Contains(other.gameObject))
                {
                    inside.Add(other.gameObject);
                }
            }

            if (other.name == "Grain")
            {
                other.tag = "InterObj";
                //other.transform.parent = transform;
                other.transform.position = grainStartPos.transform.position;
                other.transform.rotation = Quaternion.Euler(0f, 0f, 0f);
                if (!inside.Contains(other.gameObject))
                {
                    inside.Add(other.gameObject);
                }
            }
        }
    }
Пример #3
0
 protected void ItemPickedup(PickupableObject pickupable)
 {
     OnItemPickedUpCallBack?.Invoke(pickupable);
 }
Пример #4
0
 private void Start()
 {
     enemyController = this.GetComponent <EnemyCombatController>();
     pickupableEnemy = this.GetComponent <PickupableObject>();
     pickupableEnemy.CanBePickedUpAtMoment = false;
 }
Пример #5
0
    void Update()
    {
        if (PO == null)
        {
            PO = GameObject.FindObjectOfType <PickupableObject> ();
        }

        if (player == null)
        {
            player = FindObjectOfType <PlayerController> ().transform;
        }
        ImageController();
        DestroyWalls();

        if (Input.GetKey(KeyCode.Space) && hasPlayedBefore && !IngameChat.showChat)
        {
            for (int i = 0; i < TutRings.Length; i++)
            {
                Destroy(TutRings [i]);
            }

            for (int i = 0; i < walls.Length; i++)
            {
                Destroy(walls [i]);
            }

            Destroy(canvans);
            //Destroy(this);
        }

        if (TutRings [0] != null)
        {
            if (Vector3.Distance(player.transform.position, TutRings [0].transform.position) < 2)
            {
                DoorDown.Play();
                TutRing.Play();
                Invoke("DestroyDoor1", 5);
                Tut1Complete = true;
                Tut0Complete = true;
            }
        }

        if (Tut1Complete)
        {
            if (Input.GetKeyDown(KeyCode.A) && !aButton && Vector3.Distance(player.transform.position, TutRings [1].transform.position) < 2)
            {
                aButton = true;
                rotateButtons++;
                wasdGreens [0].SetActive(true);
            }

            if (Input.GetKeyDown(KeyCode.S) && !sButton && Vector3.Distance(player.transform.position, TutRings [1].transform.position) < 2)
            {
                sButton = true;
                rotateButtons++;
                wasdGreens [1].SetActive(true);
            }

            if (Input.GetKeyDown(KeyCode.D) && !dButton && Vector3.Distance(player.transform.position, TutRings [1].transform.position) < 2)
            {
                dButton = true;
                rotateButtons++;
                wasdGreens [2].SetActive(true);
            }

            if (Input.GetKeyDown(KeyCode.W) && !wButton && Vector3.Distance(player.transform.position, TutRings [1].transform.position) < 2)
            {
                wButton = true;
                rotateButtons++;
                wasdGreens [3].SetActive(true);
            }
        }

        if (TutRings [1] != null)
        {
            if (rotateButtons == 4 && Vector3.Distance(player.transform.position, TutRings [1].transform.position) < 2)
            {
                DoorDown.Play();
                TutRing.Play();
                Invoke("DestroyDoor2", 5);
                Tut2Complete  = true;
                rotateButtons = 0;


                for (int i = 0; i < wasdGreens.Length; i++)
                {
                    Destroy(wasdGreens [i]);
                }
            }
        }

        if (TutRings [2] != null)
        {
            if (Input.GetKeyDown(KeyCode.Tab) && Tut2Complete && Vector3.Distance(player.transform.position, TutRings [2].transform.position) < 2)
            {
                DoorDown.Play();
                TutRing.Play();
                Tut3Complete = true;
            }
        }

        if (TutRings [3] != null)
        {
            if (Input.GetKey(KeyCode.LeftShift) && Input.GetMouseButtonDown(0) && Tut3Complete && Vector3.Distance(player.transform.position, TutRings [3].transform.position) < 2)
            {
                DoorDown.Play();
                TutRing.Play();
                Tut4Complete = true;
            }
        }

        if (TutRings [4] != null)
        {
            if (Input.GetKey(KeyCode.T) && Tut4Complete && Vector3.Distance(player.transform.position, TutRings [4].transform.position) < 2)
            {
                DoorDown.Play();
                Tut5Complete = true;
            }
        }

        if (TutRings [5] != null)
        {
            if (Tut5Complete && Vector3.Distance(player.transform.position, TutRings [5].transform.position) < 7)
            {
                if (PO.pickupObject != null)
                {
                    Tut6Complete = true;
                }
            }
        }


        if (TutRings [6] != null)
        {
            if (Tut6Complete && Vector3.Distance(player.transform.position, TutRings [6].transform.position) < 7)
            {
                if (PO.pickupObject == null)
                {
                    Tut6Complete = false;
                    Tut7Complete = true;
                }
            }
        }

        if (TutRings [7] != null)
        {
            if (Tut7Complete && Vector3.Distance(player.transform.position, TutRings [7].transform.position) < 2)
            {
                if (Input.GetKey(KeyCode.C))
                {
                    Tut8Complete = true;
                }
            }
        }

        if (TutRings [8] != null)
        {
            if (Tut8Complete && Vector3.Distance(player.transform.position, TutRings [8].transform.position) < 2)
            {
                if (Input.GetKey(KeyCode.LeftShift) && Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftShift) && Input.GetKey(KeyCode.D))
                {
                    Tut9Complete = true;
                }
            }
        }
    }
Пример #6
0
    void placeThing(Transform thing, Transform start, Transform target)
    {
        if (thing.GetComponent <PickupableObject> ().pickupObject != null)
        {
            canPlace = thing.GetComponent <FoxPickUp> ().canPlace;
        }

        if (Vector3.Distance(thing.position, start.position) <= 2)
        {
            if (!canPlace)
            {
                return;
            }
            thing.transform.position = start.transform.position;
            PickupableObject po = thing.gameObject.GetComponent <PickupableObject> ();
            if (po.pickupObject != null)
            {
                PickupController pc = po.pickupObject.parent.parent.GetComponent <PickupController> ();
                if (pc != null)
                {
                    pc.CmdDrop(thing.gameObject);
                }
            }
            if (insideStart.Contains(thing.gameObject))
            {
                return;
            }
            insideStart.Add(thing.gameObject);
        }

        if (Vector3.Distance(thing.position, target.position) <= 2)
        {
            if (!canPlace)
            {
                return;
            }
            thing.transform.position = target.transform.position;
            PickupableObject po = thing.gameObject.GetComponent <PickupableObject> ();
            if (po.pickupObject != null)
            {
                PickupController pc = po.pickupObject.parent.parent.GetComponent <PickupController> ();
                if (pc != null)
                {
                    pc.CmdDrop(thing.gameObject);
                }
            }

            if (insideTarget.Contains(thing.gameObject))
            {
                return;
            }
            insideTarget.Add(thing.gameObject);
        }

        if (Vector3.Distance(thing.position, start.position) >= 2)
        {
            insideStart.Remove(thing.gameObject);
        }

        if (Vector3.Distance(thing.position, target.position) >= 2)
        {
            insideTarget.Remove(thing.gameObject);
        }

        /*if (thing.position != start.position && thing.position != target.position && GetComponent<PickupableObject>().pickupObject == null) {
         *
         *      thing.position = start.position;
         * }*/
    }
Пример #7
0
    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.layer == LayerMask.NameToLayer("Interactable"))
        {
            if (insideStart.Count == 3)
            {
                return;
            }

            if (insideStart.Contains(fox.gameObject) && insideStart.Contains(hen.gameObject))
            {
                //Hen Got eaten
                PickupableObject po = other.gameObject.GetComponent <PickupableObject> ();
                if (po.pickupObject != null)
                {
                    PickupController pc = po.pickupObject.parent.parent.GetComponent <PickupController> ();
                    if (pc != null)
                    {
                        pc.CmdDrop(other.gameObject);
                    }
                }
                hen.position   = henStart.transform.position;
                fox.position   = foxStart.transform.position;
                grain.position = grainStart.transform.position;
            }
            if (insideStart.Contains(grain.gameObject) && insideStart.Contains(hen.gameObject))
            {
                //Grain got eaten
                PickupableObject po = other.gameObject.GetComponent <PickupableObject> ();
                if (po.pickupObject != null)
                {
                    PickupController pc = po.pickupObject.parent.parent.GetComponent <PickupController> ();
                    if (pc != null)
                    {
                        pc.CmdDrop(other.gameObject);
                    }
                }
                hen.position   = henStart.transform.position;
                fox.position   = foxStart.transform.position;
                grain.position = grainStart.transform.position;
            }
            if (insideTarget.Contains(fox.gameObject) && insideTarget.Contains(hen.gameObject))
            {
                //Hen got eaten
                PickupableObject po = other.gameObject.GetComponent <PickupableObject> ();
                if (po.pickupObject != null)
                {
                    PickupController pc = po.pickupObject.parent.parent.GetComponent <PickupController> ();
                    if (pc != null)
                    {
                        pc.CmdDrop(other.gameObject);
                    }
                }
                hen.position   = henStart.transform.position;
                fox.position   = foxStart.transform.position;
                grain.position = grainStart.transform.position;
            }

            if (insideTarget.Contains(grain.gameObject) && insideTarget.Contains(hen.gameObject))
            {
                //Grain got eaten
                PickupableObject po = other.gameObject.GetComponent <PickupableObject> ();
                if (po.pickupObject != null)
                {
                    PickupController pc = po.pickupObject.parent.parent.GetComponent <PickupController> ();
                    if (pc != null)
                    {
                        pc.CmdDrop(other.gameObject);
                    }
                }
                hen.position   = henStart.transform.position;
                fox.position   = foxStart.transform.position;
                grain.position = grainStart.transform.position;
            }
        }
    }
Пример #8
0
 void Start()
 {
     connectedPickupableObject = GetComponentInParent <PickupableObject>();
     pickupableTipSprite       = GetComponent <SpriteRenderer>();
 }