void Start()
    {
        catapultRigidbody = GetComponent <Rigidbody2D>();
        IsTakingAimNow    = false;
        vegetableManager  = GameObject.Find("Manager").GetComponent <ObjectManagerScript>();
        vegetableManager.SetNextVagetable();
        GetComponent <LineRenderer>().startWidth = 0.2f;
        GetComponent <LineRenderer>().endWidth   = 0.05f;

        calfTrigger = transform.Find("CalfTrigger").GetComponent <PolygonCollider2D>();
        startPoint  = CurrentVegetable.GetComponent <Rigidbody2D>().position;

        trajectoryLine = GetComponent <LineRenderer>();
        leftElastic    = transform.Find("LeftElastic").GetComponent <LineRenderer>();
        rightElastic   = transform.Find("RightElastic").GetComponent <LineRenderer>();

        leftLowerBlack = transform.Find("LeftLowerBlack").GetComponent <LineRenderer>();
        leftUpperBlack = transform.Find("LeftUpperBlack").GetComponent <LineRenderer>();

        rightLowerBlack = transform.Find("RightLowerBlack").GetComponent <LineRenderer>();
        rightUpperBlack = transform.Find("RightUpperBlack").GetComponent <LineRenderer>();

        leftElastic.positionCount  = 2;
        rightElastic.positionCount = 2;

        leftLowerBlack.positionCount = 2;
        leftUpperBlack.positionCount = 2;

        rightLowerBlack.positionCount = 2;
        rightUpperBlack.positionCount = 2;

        MoveCalf(true);
    }
Exemple #2
0
 void OnDestroy()
 {
     if (ObjectManagerScript.Instance())
     {
         ObjectManagerScript.Instance().UnRegisterBoardObject();
     }
 }
Exemple #3
0
 // Use this for initialization
 void Start()
 {
     loginScript   = GameObject.Find("LoginPanel").GetComponent <LoginScript>();
     loginPanel    = GameObject.Find("LoginPanel");
     objectManager = GameObject.Find("ObjectManager").GetComponent <ObjectManagerScript>();
     playerScript  = GameObject.Find("PlayerManager").GetComponent <PlayerScript>();
 }
Exemple #4
0
 void OnDestroy()
 {
     if (ObjectManagerScript.Instance())
     {
         ObjectManagerScript.Instance().UnRegisterCursorObject(gameObject);
     }
     Screen.showCursor = true;
 }
Exemple #5
0
 public static ObjectManagerScript GetInstance()
 {
     if (instance == null)
     {
         instance = FindObjectOfType <ObjectManagerScript>();
     }
     return(instance);
 }
Exemple #6
0
 void OnDestroy()
 {
     if (Network.isServer)
     {
         if (ObjectManagerScript.Instance())
         {
             ObjectManagerScript.Instance().UnRegisterGrabbableObject(gameObject);
         }
     }
 }
Exemple #7
0
 void Start()
 {
     if (Network.isServer)
     {
         if (ObjectManagerScript.Instance())
         {
             ObjectManagerScript.Instance().RegisterGrabbableObject(gameObject);
         }
     }
 }
Exemple #8
0
    void StartZoom()
    {
        var cursor = ObjectManagerScript.Instance().GetMyCursorObject();

        if (cursor)
        {
            target_rotation.SetLookRotation(cursor.transform.position - transform.position, old_rotation * new Vector3(0, 1, 0));
        }
        zoomed = true;
    }
Exemple #9
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.CompareTag("Player") && !isEntered)
        {
            isEntered = true;
            keySound.Play();

            ObjectManagerScript.GetInstance().InstantiateKey();
        }
    }
Exemple #10
0
 void Start()
 {
     if (networkView.isMine)
     {
         SpawnDice();
     }
     if (ObjectManagerScript.Instance())
     {
         ObjectManagerScript.Instance().RegisterBoardObject(gameObject);
     }
 }
Exemple #11
0
    // Update is called once per frame
    void Update()
    {
        var cursor = ObjectManagerScript.Instance().GetMyCursorObject();

        if (cursor)
        {
            old_rotation = transform.rotation;
            transform.LookAt(cursor.transform.position, GameObject.Find("Main Camera").transform.up);
            transform.rotation = Quaternion.Lerp(transform.rotation, old_rotation, Mathf.Pow(ZOOM_INERTIA, Time.deltaTime));
            //transform.up = GameObject.Find("Main Camera").transform.up;
        }
    }
Exemple #12
0
 void Start()
 {
     if (networkView.isMine)
     {
         id_ = Net.GetMyID();
     }
     if (ObjectManagerScript.Instance())
     {
         ObjectManagerScript.Instance().RegisterCursorObject(gameObject);
     }
     Screen.showCursor = false;
 }
Exemple #13
0
 void OnCollisionEnter(Collision info)
 {
     if (info.relativeVelocity.magnitude > 1.0f && Time.time > last_sound_time + PHYSICS_SOUND_DELAY)
     {
         float volume = info.relativeVelocity.magnitude * 0.1f;
         ImpactSound(volume);
         last_sound_time = Time.time;
     }
     if (Network.isServer)
     {
         if (info.collider.GetComponent <DeckScript>())
         {
             ObjectManagerScript.Instance().NotifyDeckHitDeck(gameObject, info.collider.gameObject);
         }
     }
 }
Exemple #14
0
    void Start()
    {
        manager = GameObject.Find("Manager").GetComponent <ObjectManagerScript>();
        GameObject.Find("Manager").GetComponent <ObjectManagerScript>().LevelEnded = true;
        nextLevel = GameObject.Find("Manager").GetComponent <ObjectManagerScript>().CurrentLevelNumber + 1;
        RestartButton.onClick.AddListener(RestartButtonListener);
        NextLevelButton.onClick.AddListener(NextLevelButtonListener);
        LevelSelectionButton.onClick.AddListener(LevelSelectionButtonListener);
        GetComponent <PullObjects>().Initiate();
        //GameObject.Find("EventSystem").GetComponent<PullObjects>().Initiate();
        int totalLevelCount = GetComponent <PullObjects>().Levels.Count;

        //disable NextLevelButton if next level is blocked
        if ((GameObject.Find("Manager").GetComponent <ObjectManagerScript>().CurrentLevelNumber == ProgressManagerComponent.LastAvaliableLevelId && !LevelCompleted) || nextLevel >= totalLevelCount)
        {
            NextLevelButton.interactable = false;
        }
        CoinsText.text = "" + ProgressManagerComponent.AmountOfMoney;
        GetComponent <SoundManagerComponent>().PlaySound("LevelEndSound");
    }
Exemple #15
0
    void OnDestroy()
    {
        if (GetComponent <VibrationManagerComponent>().GetEnableVibration().Equals(1f))
        {
            GameObject          manager             = GameObject.Find("Manager");
            ObjectManagerScript objectManagerScript = null;
            try
            {
                objectManagerScript = manager.GetComponent <ObjectManagerScript>();
            }
            catch (Exception e)
            {
                print(e);
            }

            if (objectManagerScript != null && !objectManagerScript.LevelEnded)
            {
                Handheld.Vibrate();
            }
        }
    }
Exemple #16
0
 public void TellObjectManagerAboutMouseRelease(int player_id)
 {
     ObjectManagerScript.Instance().ClientReleasedMouse(player_id);
 }
Exemple #17
0
 public void TellObjectManagerAboutCardPeel(int grab_id, int player_id)
 {
     ObjectManagerScript.Instance().ClientCardPeel(grab_id, player_id);
 }
Exemple #18
0
    void DrawGameGUI()
    {
        if (chat_shown_)
        {
            if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Return)
            {
                if (chat_.Length > 0)
                {
                    SendChatMessage(chat_);
                }
                chat_       = "";
                chat_shown_ = false;
                GUI.FocusControl("TheLabel");
                Event.current.Use();
            }
            if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape)
            {
                chat_       = "";
                chat_shown_ = false;
                GUI.FocusControl("TheLabel");
                Event.current.Use();
            }
        }
        else
        {
            if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Return)
            {
                chat_shown_ = true;
                //ConsoleScript.Log ("Showing chat");
                Event.current.Use();
            }
        }

        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Exit Game"))
        {
            Network.Disconnect();
            Application.LoadLevel(Application.loadedLevel);
        }
        GUILayout.EndHorizontal();

        /*GUILayout.BeginHorizontal();
         * if(GUILayout.Button("Copy Join URL To Clipboard")){
         *      RequestPageURLForCopyGameJoin();
         * }
         * GUILayout.EndHorizontal();*/
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Restart Game"))
        {
            ObjectManagerScript.Instance().RecoverDice();
        }
        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal();
        GUILayout.Label(game_name_);
        GUILayout.EndHorizontal();
        Dictionary <int, PlayerInfo> player_info_list = PlayerListScript.Instance().GetPlayerInfoList();

        foreach (var pair in player_info_list)
        {
            GUI.contentColor = pair.Value.color_;
            GUILayout.BeginHorizontal();
            GUILayout.Label(pair.Key + ": " + pair.Value.name_);
            GUILayout.EndHorizontal();
            GUI.contentColor = Color.white;
        }


        GUILayout.BeginArea(new Rect(Screen.width - 200, 0, 200, 300));
        if (!help_shown_)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label("Press '?' for help", help_gui_skin.label);
            GUILayout.EndHorizontal();
        }
        else
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label("Press '?' to close help", help_gui_skin.label);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Press 'Z' to zoom in", help_gui_skin.label);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Press 'WASD' to move while zoomed", help_gui_skin.label);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Press 'Q' or 'E' to rotate cards", help_gui_skin.label);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Press 'R' to rotate a card to be readable", help_gui_skin.label);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Press 'F' to flip cards", help_gui_skin.label);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Press 'T' to tap tokens", help_gui_skin.label);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Press 'RETURN' to chat", help_gui_skin.label);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Press '1-5' to play different songs", help_gui_skin.label);
            GUILayout.EndHorizontal();
        }
        GUILayout.EndArea();

        if (chat_shown_)
        {
            GUILayout.BeginArea(new Rect(Screen.width * 0.5f - 200, Screen.height - 30, 400, 200));
            GUILayout.BeginHorizontal();
            GUI.SetNextControlName("TheLabel");
            GUILayout.Label("Chat:");
            GUI.SetNextControlName("ChatField");
            chat_ = GUILayout.TextField(chat_, GUILayout.MinWidth(350));
            if (chat_.Length > 90)
            {
                chat_ = chat_.Substring(0, 90);
            }
            GUI.FocusControl("ChatField");
            GUILayout.EndHorizontal();
            GUILayout.EndArea();
        }
        if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Slash)
        {
            help_shown_ = !help_shown_;
            Event.current.Use();
        }
    }