Esempio n. 1
0
    private static void NumberInputProcessed(bool del)
    {
        GameObject            player = GameObject.Find("LOCAL Player");
        NetworkedPlayerScript nps    = player.GetComponent <NetworkedPlayerScript>();

        bool shouldClear = true;

        if (numberTextField.text != null)
        {
            int input = -1;
            if (System.Int32.TryParse(numberTextField.text, out input))
            {
                if (nps.GetColor() != input)
                {
                    if (nps.DoesPlayerNumberExist(input) != -1)
                    {
                        GUIManagerScript.SetNumberInputFieldColor(ColorScript.GetColor(input), true);
                        shouldClear = false;
                    }
                }
            }
        }

        if (shouldClear)
        {
            Color clr = ColorScript.GetColor(nps.GetColor());
            clr = clr * 0.5f;
            GUIManagerScript.SetNumberInputFieldColor(clr);

            if (del)
            {
                GUIManagerScript.ClearNumberInput();
            }
        }
    }
Esempio n. 2
0
    public static Color generateNewColor()
    {
        float period = Random.Range(0.055f, 1);
        Color col    = ColorScript.GetColor(period);

        return(col);
    }
Esempio n. 3
0
    // Start is called before the first frame update
    void Start()
    {
        audio       = GetComponent <AudioSource>();
        colorScript = GetComponent <ColorScript>();
        animator    = GetComponent <Animator>();
        switch (own)
        {
        case PlayerKind.Player1:
            hp = MultiPlayerManager.instance.P1Dot;
            break;

        case PlayerKind.Player2:
            hp = MultiPlayerManager.instance.P2Dot;
            break;

        case PlayerKind.Player3:
            hp = MultiPlayerManager.instance.P3Dot;
            break;

        case PlayerKind.Player4:
            hp = MultiPlayerManager.instance.P4Dot;
            break;

        default:
            Debug.LogError("よばれちゃいけんのやぞ");
            break;
        }
        padNum = (int)own + 1;
        //weaponNumber = weapon.Length;
        //createNum = weapon[weaponType].GetComponent<weapon>().parametor.dotNum;
        create = GetComponent <WeaponCreate>();
        //this.gameObject.transform.LookAt(GameObject.Find("Tower").transform);
    }
Esempio n. 4
0
    public void RpcCountdown(bool l)
    {
        GUIManagerScript.SetEndGameScreen(false);
        if (l)
        {
            //playerParent.GetComponent<PlayerParentScript>().LockAndSpin();
            AudioManagerScript.instance.PrepareGameMusic();
            AudioManagerScript.instance.PlayCountdown();
            GUIManagerScript.SetRulesButton(false);
            GUIManagerScript.SetInput(false);
        }
        else
        {
            //playerParent.GetComponent<PlayerParentScript>().Unlock();
            Debug.Log("Countdown stopped!");
            AudioManagerScript.instance.StopSFX();
            AudioManagerScript.instance.StartMenuMusic();
            GUIManagerScript.SetRulesButton(true);
            GUIManagerScript.SetInput(true);

            if (networkedPScript == null)
            {
                SetNPS();
            }
            if (networkedPScript.nameText == ColorScript.GetColorName(networkedPScript.GetColor()))
            {
                networkedPScript.nameText = "";
                GUIManagerScript.FillPlayerText("");
            }
        }
    }
Esempio n. 5
0
//	void OnGUI(){
//		GUI.Label (new Rect (10, 25, 150, 150), "Bullets Fired: " + totalBulletsFired);
//	}

	public void NewRand(){
		number = Random.Range(0,9);
		switch (number) {
		case 0:	
			CS = GameObject.Find ("Pink").GetComponent<ColorScript> ();
			break;
		case 1:	
			CS = GameObject.Find ("Red").GetComponent<ColorScript> ();
			break;
		case 2:	
			CS = GameObject.Find ("Orange").GetComponent<ColorScript> ();
			break;
		case 3:	
			CS = GameObject.Find ("Yellow").GetComponent<ColorScript> ();
			break;
		case 4:	
			CS = GameObject.Find ("Green").GetComponent<ColorScript> ();
			break;
		case 5:	
			CS = GameObject.Find ("Blue").GetComponent<ColorScript> ();
			break;
		case 6:	
			CS = GameObject.Find ("Purple").GetComponent<ColorScript> ();
			break;
		case 7:	
			CS = GameObject.Find ("Brown").GetComponent<ColorScript> ();
			break;
		case 8:	
			CS = GameObject.Find ("Black").GetComponent<ColorScript> ();
			break;
		}
		CS.ColSwitch ();
	}
Esempio n. 6
0
    void Awake()
    {
        // Get Components
        controls = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerMovementController>();

        colorscript = GetComponentInParent <ColorScript>();
    }
Esempio n. 7
0
    private void UpdateColor(float currentPosition)
    {
        textDebug.text  = "Mouse : " + Input.GetMouseButton(0);
        textDebug.text += "\ncurrentPosition : " + currentPosition;
        textDebug.text += "\npreviousPosition : " + previousPosition;
        textDebug.text += "\nchangingColor : " + isChangingColor;
        textDebug.text += "\nsaveFile : " + FileManagerScript.pathForDocumentsFile("colorSave");

        if (isChangingColor)
        {
            UpdateDirection(currentPosition);
            textDebug.text += "\ngoingUp : " + isGoingUp;

            previousPosition = currentPosition;

            float period = GetAverage(periods.ToArray());
            textDebug.text += "\nperiod : " + period;

            Color col = ColorScript.GetColor(period);
            lightGenerator.GetComponent <SpriteRenderer>().color = col;
            sin.GetComponent <SinWaveScript>().period            = period;
            sin.GetComponent <SinWaveScript>().c2 = col;
            textDebug.text += "\ncolor : " + col;

            while (periods.ToArray().Length > numberAveraged)
            {
                periods.Dequeue();
            }
        }
    }
Esempio n. 8
0
 void SetColor()
 {
     if (color != -1)
     {
         Color c = ColorScript.GetColor(color);
         playerButton.GetComponent <Image>().color = c;
     }
 }
    public void RpcStartGame(int s)
    {
        songID            = s;
        scored_ThisRound  = 0;
        scored_TimeBonus  = 0;
        scored_FirstBonus = false;
        scored_WasGuessed = false;

        //playerParent.GetComponent<PlayerParentScript>().Unlock();

        // Bullshit code. Temp? Maybe not?
        // What if player WAS ready, but now that we're actually starting they are no longer?
        // Too late for them! Let's double check
        if (!ready)
        {
            Assert.IsFalse(ready, "Player wasn't ready, but the server thought they were!");
            // Oh noes! What do we do? Let's cheat:
            SetReady(true);
            // See buddy, you were ready the whole time, right?
        }
        ResetMatch();

        if (isLocalPlayer)
        {
            GUIManagerScript.SetButton(false);

            GUIManagerScript.SetBackButton(false);

            Color clr = ColorScript.GetColor(GetColor());
            clr = clr * 0.5f;
            GUIManagerScript.SetNumberInputFieldColor(clr);
            GUIManagerScript.ClearNumberInput();
            GUIManagerScript.SetSongSetButton(false);

            //Hacky bullshit for finding which kind of game we're in?
            GameManagerScript gameManager = FindObjectOfType <GameManagerScript>();
            Assert.IsNotNull <GameManagerScript>(gameManager);
            int index = gameManager.GetSongSet();

            AudioManagerScript.instance.StartGameMusic(index);

            GUIManagerScript.SetClassicGameParent(color, ColorScript.GetColor(color), ColorScript.GetColorName(color));

            localPScript.reminded = false;
        }

        List <CaptainsMessPlayer> players = GetPlayers();

        foreach (CaptainsMessPlayer player in players)
        {
            NetworkedPlayerScript nps = player.GetComponent <NetworkedPlayerScript>();
            if (!nps.isLocalPlayer)
            {
                player.GetComponent <NetworkedPlayerScript>().playerButton.SetActive(true);
                player.GetComponent <NetworkedPlayerScript>().playerButton.GetComponent <Button>().interactable = true;
            }
        }
    }
 void SetColor()
 {
     if (color != -1)
     {
         Color c = ColorScript.GetColor(color);
         playerButton.GetComponent <Image>().color         = c;
         playerButton.GetComponentInChildren <Text>().text = color.ToString();
     }
 }
Esempio n. 11
0
 private void OnTriggerStay(Collider other)
 {
     if (other.tag == "Conveyed")
     {
         colorScript             = other.gameObject.GetComponent <ColorScript>();                      //Upon collision with a
         cannonScript.colorValue = colorScript.colorValue;                                             //conveyed object, store
         Instantiate(octopiPrefab, prefabLoc.transform.position, octopiPrefab.transform.rotation);     //colour value and instantiate
         Destroy(other.gameObject);                                                                    //throwable object in cannon
     }
 }
Esempio n. 12
0
    public Order(Color color, int id, Table table)
    {
        this.table    = table;
        this.color    = color;
        this.id       = id;
        foodLeftToEat = new List <int>(table.SittingCustomers.numberOfCustomers);

        table.OrderSphereInteractive.SetAction(PlaceOrder);
        ColorScript.SetColor(table.OrderSphereInteractive.gameObject, color);
    }
Esempio n. 13
0
    public void LoadColor()
    {
        ColorScript mColor = JsonUtility.FromJson <ColorScript>(File.ReadAllText(Application.persistentDataPath + "/Color.json"));

        mPlayer1.GetComponent <SpriteRenderer>().color = mColor.mPlayer1Color;
        mPlayer2.GetComponent <SpriteRenderer>().color = mColor.mPlayer2Color;
        mPlayer3.GetComponent <SpriteRenderer>().color = mColor.mPlayer3Color;
        mPlayer4.GetComponent <SpriteRenderer>().color = mColor.mPlayer4Color;
        mResumeButtonClicked = mColor.mResumeButtonClicked;
    }
Esempio n. 14
0
 // Use this for initialization
 void Start()
 {
     thisRenderer = gameObject.GetComponent <SpriteRenderer>();
     fireFlyColor = ColorScript.generateNewColor();
     halo         = (Behaviour)GetComponent("Halo");
     thisRenderer.material.SetColor("_DesiredColor", fireFlyColor);
     sourceRenderer = GameObject.Find("FlashLight").GetComponent <SpriteRenderer>();
     halo.GetComponent <SpriteRenderer>().sortingLayerID = thisRenderer.sortingLayerID;
     halo.GetComponent <SpriteRenderer>().sortingOrder   = thisRenderer.sortingOrder;
 }
Esempio n. 15
0
    public static Color GetColor(float period)
    {
        float[] rgb = ColorScript.getRGB(convertToWavelength(period));
        // Debug.Log("[" + rgb[0] + " , " + rgb[1] + " , " + rgb[2] + "]");
        Color col = new Color(flattenRgb(rgb[0]),
                              flattenRgb(rgb[1]),
                              flattenRgb(rgb[2]));

        return(col);
    }
Esempio n. 16
0
 private void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(gameObject);
     }
     else
     {
         instance = this;
         DontDestroyOnLoad(gameObject);
     }
 }
Esempio n. 17
0
    void Start()
    {
        levelData     = FindObjectOfType(typeof(LevelData)) as LevelData;
        colorScript   = FindObjectOfType(typeof(ColorScript)) as ColorScript;
        counterScript = FindObjectOfType(typeof(InGameBallCounterScript)) as InGameBallCounterScript;
        cameraScaler  = FindObjectOfType(typeof(CameraScaler)) as CameraScaler;


        reversedCameraQuaternion = new Quaternion(180f, 0, 0, 0);

        CreateLevel();
    }
Esempio n. 18
0
 private void Start()
 {
     mNumberOfPlayers = 0;
     mPlayerIndex     = 0;
     jsonSavePath     = Application.persistentDataPath + "/Data.json";
     mData            = new DataScript();
     mPoints          = new PointsScript();
     mColor           = new ColorScript();
     mMainMenu.SetActive(true);
     LoadColor();
     Load();
     LoadGameEndData();
 }
Esempio n. 19
0
    public void SaveColor()
    {
        ColorScript mNewColor = new ColorScript();

        mNewColor.mPlayer1Color        = mPlayer1;
        mNewColor.mPlayer2Color        = mPlayer2;
        mNewColor.mPlayer3Color        = mPlayer3;
        mNewColor.mPlayer4Color        = mPlayer4;
        mNewColor.mResumeButtonClicked = true;
        string mJsonString = JsonUtility.ToJson(mNewColor, true);

        File.WriteAllText(Application.persistentDataPath + "/Color.json", mJsonString);
    }
Esempio n. 20
0
    public void OnNameTextChanged(string s)
    {
        if (s == "")
        {
            nameText = ColorScript.GetColorName(color);
        }
        else
        {
            nameText = s;
        }

        playerButton.GetComponentInChildren <Text>().text = nameText;
        to_sort = true;
    }
Esempio n. 21
0
    public void RpcStartGame(int s)
    {
        songID            = s;
        scored_ThisRound  = 0;
        scored_TimeBonus  = 0;
        scored_FirstBonus = false;
        scored_WasGuessed = false;

        //playerParent.GetComponent<PlayerParentScript>().Unlock();

        // Bullshit code. Temp? Maybe not?
        // What if player WAS ready, but now that we're actually starting they are no longer?
        // Too late for them! Let's double check
        if (!ready)
        {
            Assert.IsFalse(ready, "Player wasn't ready, but the server thought they were!");
            // Oh noes! What do we do? Let's cheat:
            SetReady(true);
            // See buddy, you were ready the whole time, right?
        }
        ResetMatch();

        if (isLocalPlayer)
        {
            GUIManagerScript.FillPlayerText(nameText);

            GUIManagerScript.SetButton(false);

            GUIManagerScript.DisableInput(true);
            GUIManagerScript.SetBackButton(false);

            AudioManagerScript.instance.StartGameMusic();

            GUIManagerScript.SetColorShow(nameText, ColorScript.GetColor(color), ColorScript.GetColorName(color));

            localPScript.reminded = false;
        }

        List <CaptainsMessPlayer> players = GetPlayers();

        foreach (CaptainsMessPlayer player in players)
        {
            NetworkedPlayerScript nps = player.GetComponent <NetworkedPlayerScript>();
            if (!nps.isLocalPlayer)
            {
                player.GetComponent <NetworkedPlayerScript>().playerButton.SetActive(true);
                player.GetComponent <NetworkedPlayerScript>().playerButton.GetComponent <Button>().interactable = true;
            }
        }
    }
Esempio n. 22
0
    void Start()
    {
        SaveGameEndData();
        BackGroundSize();
        mJsonSavePath               = Application.persistentDataPath + "/Color.json";
        mColor                      = new ColorScript();
        mColor.mPlayer1Color        = mPlayer1;
        mColor.mPlayer2Color        = mPlayer2;
        mColor.mPlayer3Color        = mPlayer3;
        mColor.mPlayer4Color        = mPlayer4;
        mColor.mResumeButtonClicked = false;
        string mJsonData = JsonUtility.ToJson(mColor, true);

        File.WriteAllText(mJsonSavePath, mJsonData);
    }
Esempio n. 23
0
    public override void OnInspectorGUI()
    {
        //if (!GUI.changed)
        //return;

        EditorGUIUtility.LookLikeControls();
        serializedObject.Update();

        ColorScript t = (ColorScript)target as ColorScript;

        t.ColorName = (ColorScript.ColorNames)EditorGUILayout.EnumPopup("ColorName", t.ColorName);
        t.isRandom  = EditorGUILayout.Toggle("Is Random", t.isRandom);

        serializedObject.ApplyModifiedProperties();
        EditorGUIUtility.LookLikeInspector();
    }
Esempio n. 24
0
 // collision checks, which only matter for the balls fired at players marked "Harmful"
 void OnCollisionEnter(Collision col)
 {
     if (col.gameObject.tag == "Harmful")
     {
         // we have to first check the color of the ball, as if it matches the color of the player then it is destroyed with no consequence, otherwise it kills the player
         ColorScript colorComponent = col.gameObject.GetComponent <ColorScript>();
         if ((colorComponent && colorComponent.IsMyColor(Player1)))
         {
             col.gameObject.GetComponent <BallScript>().DestroyBall();
         }
         else if (!colorComponent || (colorComponent && !colorComponent.IsMyColor(Player1)))
         {
             Respawn();
         }
     }
 }
    void RpcSetColor(int c)
    {
        color   = c;
        to_sort = true;

        SetColor();

        if (isLocalPlayer)
        {
            string clr_name = ColorScript.GetColorName(c);

            Color clr = ColorScript.GetColor(c);
            GUIManagerScript.SetInputColor(clr, clr_name);
            clr = clr * 0.5f;
            GUIManagerScript.SetBGColor(clr);
            GUIManagerScript.FillPlayerNumber(c);
            GUIManagerScript.SetNumberInputFieldColor(clr);
            GUIManagerScript.ClearNumberInput();
        }
    }
 private void Start()
 {
     mColor = new ColorScript();
     mColor = JsonUtility.FromJson <ColorScript>(File.ReadAllText(Application.persistentDataPath + "/Color.json"));
     if (gameObject.CompareTag("Player1"))
     {
         gameObject.GetComponent <SpriteRenderer>().color = mColor.mPlayer1Color;
     }
     else if (gameObject.CompareTag("Player2"))
     {
         gameObject.GetComponent <SpriteRenderer>().color = mColor.mPlayer2Color;
     }
     else if (gameObject.CompareTag("Player3"))
     {
         gameObject.GetComponent <SpriteRenderer>().color = mColor.mPlayer3Color;
     }
     else if (gameObject.CompareTag("Player4"))
     {
         gameObject.GetComponent <SpriteRenderer>().color = mColor.mPlayer4Color;
     }
 }
Esempio n. 27
0
    void RpcSetColor(int c)
    {
        int oldColor = color;

        color = c;
        SetColor();

        string clr_name = ColorScript.GetColorName(c);

        if (isLocalPlayer)
        {
            Color clr = ColorScript.GetColor(c);
            GUIManagerScript.SetInputColor(clr, clr_name);
            clr = clr * 0.5f;
            GUIManagerScript.SetBGColor(clr);
        }

        if (nameText == ColorScript.GetColorName(oldColor) || nameText == "")
        {
            OnNameTextChanged(clr_name);
        }
    }
Esempio n. 28
0
    //改變顏色
    private IEnumerator ChangeColorEnumerator(ColorScript info)
    {
        bool  playing     = true;
        float timer       = 0;                     //計時器
        float endTime     = info.GetEndTime();     //動畫結束時間
        float denominator = info.GetDenominator(); //動畫進度分母
        Image img         = this.GetComponent <Image>();

        if (!img.enabled)
        {
            img.enabled = true;
        }

        Color32[] alteration = new Color32[2] {
            info.insOutsColors.Length == 2 ? info.insOutsColors[0] : (Color32)this.GetComponent <Image>().color, info.insOutsColors[info.insOutsColors.Length - 1]
        };                                                                                                                                                                                               //重新定義起始與目標顏色
        info.insOutsColors = alteration;

        while (playing) //變化過程
        {
            timer = timer + Time.fixedDeltaTime > endTime ? endTime : timer + Time.fixedDeltaTime;

            float r = alteration[0].r + ((alteration[1].r - alteration[0].r) * (info.GetNumerator(timer) / denominator));
            float g = alteration[0].g + ((alteration[1].g - alteration[0].g) * (info.GetNumerator(timer) / denominator));
            float b = alteration[0].b + ((alteration[1].b - alteration[0].b) * (info.GetNumerator(timer) / denominator));
            float a = alteration[0].a + ((alteration[1].a - alteration[0].a) * (info.GetNumerator(timer) / denominator));
            img.color = new Color32((byte)Mathf.Clamp(r, 0, 255), (byte)Mathf.Clamp(g, 0, 255), (byte)Mathf.Clamp(b, 0, 255), (byte)Mathf.Clamp(a, 0, 255));

            if (timer == endTime)
            {
                playing = false;
            }
            yield return(new WaitForFixedUpdate());
        }

        info.isPlaying = false;

        yield return(null);
    }
Esempio n. 29
0
    void Update()
    {
        GameManagerScript gameManager = FindObjectOfType <GameManagerScript>();

        Assert.IsNotNull <GameManagerScript>(gameManager);

        if (gameManager.IsInPostGame())
        {
            sliderText.text = "";

            infoText.enabled      = false;
            countdownText.enabled = false;

            string details = "";

            if (networkedPScript.GetFirstBonus())
            {
                details = "(First to guess: +100)\n";
            }

            int song  = networkedPScript.GetSongID();
            int match = networkedPScript.GetMatchSongID();

            int songTypeIndex = gameManager.GetSongSet();


            if (match != -1)
            {
                answerParent.SetActive(true);
                playerPickedBtn.GetComponent <Image>().color         = ColorScript.GetColor(networkedPScript.picked_color);
                playerPickedBtn.GetComponentInChildren <Text>().text = networkedPScript.picked_color.ToString();
                noGuessText.enabled = false;

                if (song == match)
                {
                    lookingForParent.SetActive(false);

                    answerText.text = "Correct!";
                    details        += "(Found Dance Partner: +250)\n(Time Bonus: +" + networkedPScript.GetTimeBonus() + ")\n";

                    listeningToText.text = "You were dancing to:\n" + AudioManagerScript.GetSongName(songTypeIndex, song);
                }
                else
                {
                    lookingForParent.SetActive(true);

                    lookingForBtn.GetComponent <Image>().color         = ColorScript.GetColor(networkedPScript.match_color);
                    lookingForBtn.GetComponentInChildren <Text>().text = networkedPScript.match_color.ToString();

                    answerText.text = "Wrong!";

                    listeningToText.text = "You heard: " + AudioManagerScript.GetSongName(songTypeIndex, song) + "\nThey heard: " + AudioManagerScript.GetSongName(songTypeIndex, match);
                }
            }
            else
            {
                lookingForParent.SetActive(false);
                answerParent.SetActive(false);
                noGuessText.enabled = true;

                listeningToText.text = "You were dancing to:\n" + AudioManagerScript.GetSongName(songTypeIndex, song);
            }

            finalScoreText.text = "Score: +" + networkedPScript.GetScoredThisRound().ToString();

            if (networkedPScript.GetWasGuessed())
            {
                details += "(Partner found you: +500)";
            }

            if (details != "")
            {
                details = "Score breakdown:\n" + details;
            }

            detailsText.text = details;

            continuingInText.text = "Automatically continuing in " + Mathf.CeilToInt(gameManager.endgameCountDown);
        }
        else
        {
            float countDown = gameManager.countDown;

            float captainsCountdown = networkedPScript.captainsCountdown;
            if (captainsCountdown > 0)
            {
                sliderText.text  = "";
                infoText.enabled = true;

                if (captainsCountdown < 1)
                {
                    infoText.text = "DANCE!";
                }
                else if (captainsCountdown >= (4f)) //Plus one second for the "Dance" end
                {
                    infoText.text = "Ready?";
                }
                else
                {
                    infoText.text = "" + Mathf.Floor(captainsCountdown);
                }
            }
            else if (countDown > 0)
            {
                bool chosen = (networkedPScript.GetMatchSongID() == -1);
                if (chosen)
                {
                    sliderText.text = "Chose your dance partner:";
                }
                else
                {
                    sliderText.text = "Press back to undo current choice";
                }
                infoText.enabled      = false;
                countdownText.enabled = true;
                countdownText.text    = "" + Mathf.Ceil(countDown);

                if (reminded == false)
                {
                    if (countDown < 30 && chosen)
                    {
                        Debug.Log("Reminder to pick!");
                        AudioManagerScript.instance.PlayFind();
                        reminded = true;
                    }
                }
            }
            else
            {
                sliderText.text  = "Other players:";
                infoText.enabled = false;
            }
        }
    }
Esempio n. 30
0
    // trigger checks, which all have to do with potential melding objects
    void OnTriggerStay(Collider col)
    {
        ColorScript colorComponent = col.gameObject.GetComponent <ColorScript>();

        // firstly if the object has a color attribute and it doesn't match the players then it can't be used
        if (!colorComponent || (colorComponent && ((colorComponent.isWhite && !Player1) || (!colorComponent.isWhite && Player1))))
        {
            // here we display the ui prompt for entering a meld-able object now that we're close enough
            if ((col.gameObject.tag == "Screw" && !col.GetComponentInParent <ScrewScript>().player) || (col.gameObject.tag == "SingleControlRock" && !col.GetComponent <SingleControlRock>().player1) || (col.gameObject.tag == "Switch" && !col.GetComponentInParent <ScrewScript>().player) || (col.gameObject.tag == "EndObject" && (!col.GetComponentInParent <EndObject>().player1 || !col.GetComponentInParent <EndObject>().player2)))
            {
                buttonPromptOn = true;
                timeStart      = Time.time;
            }
            else
            {
                buttonPromptOn = false;
            }

            // if the player hits the square button and the object nearby is meld-able (i.e. a switch, screw, or control rock), then we call the meld in function to transition the player there
            if (col.gameObject.tag == "Switch" && (Input.GetButtonDown(mySButton)))
            {
                if (!col.GetComponentInParent <SwitchScript>().player1)
                {
                    anim.CrossFade("Meld");
                    melding = true;
                }
            }

            if (col.gameObject.tag == "Screw")
            {
                // if they are colliding and pressing the enter button we begin the meld process
                if ((Input.GetButtonDown(mySButton)) && !col.GetComponentInParent <ScrewScript>().player&& !col.GetComponentInParent <ScrewScript>().locked&& !melding && !meldDone)
                {
                    this.gameObject.transform.GetChild(2).forward = (col.transform.position - transform.position);
                    anim.CrossFade("Meld");
                    melding        = true;
                    buttonPromptOn = false;
                    col.GetComponentInParent <ScrewScript>().locked = true;
                }
                // otherwise, if they are in an object range and have gone through a meld animation, we transfer the player to the object
                else if (meldDone)
                {
                    col.GetComponentInParent <ScrewScript>().player      = this.gameObject;
                    col.GetComponentInParent <ScrewScript>().justEntered = true;
                    meldDone = false;

                    //Play meld sound
                    soundSource.Stop();
                    soundSource.PlayOneShot(meld, 1.0f);

                    //Legacy animations dont support events on animation, so there is no way
                    //to make the animation play before this happens.
                    //Making this function an IEnumerator will break it as well

                    characterRenderer.enabled = false;
                    transform.GetComponent <Collider>().enabled = false;
                    if (Player1)
                    {
                        myCamera.GetComponent <CameraScript>().player1 = col.gameObject;
                    }
                    else
                    {
                        myCamera.GetComponent <CameraScript>().player2 = col.gameObject;
                    }

                    col.GetComponentInParent <ScrewScript>().locked = false;

                    buttonPromptOn = false;

                    this.transform.position -= new Vector3(0, 100, 0);
                }
            }

            if (col.gameObject.tag == "SingleControlRock")
            {
                // if they are colliding and pressing the enter button we begin the meld process
                if (Input.GetButtonDown(mySButton) && !col.GetComponent <SingleControlRock>().player1&& !col.GetComponent <SingleControlRock>().locked&& !melding && !meldDone)
                {
                    this.gameObject.transform.GetChild(2).forward = (col.transform.position - transform.position);
                    anim.CrossFade("Meld");
                    melding = true;
                    col.GetComponent <SingleControlRock>().locked = true;
                    buttonPromptOn = false;
                }
                // otherwise, if they are in an object range and have gone through a meld animation, we transfer the player to the object
                else if (meldDone)
                {
                    col.GetComponentInParent <SingleControlRock>().player1     = this.gameObject;
                    col.GetComponentInParent <SingleControlRock>().justEntered = true;

                    //Play meld sound
                    soundSource.Stop();
                    soundSource.PlayOneShot(meld, 1.0f);

                    //Legacy animations dont support events on animation, so there is no way
                    //to make the animation play before this happens.
                    //Making this function an IEnumerator will break it as well

                    characterRenderer.enabled = false;
                    transform.GetComponent <Collider>().enabled = false;
                    if (Player1)
                    {
                        myCamera.GetComponent <CameraScript>().player1 = col.gameObject;
                    }
                    else
                    {
                        myCamera.GetComponent <CameraScript>().player2 = col.gameObject;
                    }

                    col.GetComponent <SingleControlRock>().locked = false;

                    this.transform.position -= new Vector3(0, 100, 0);

                    meldDone = false;
                }
            }

            if (col.gameObject.tag == "EndObject")
            {
                // if they are colliding and pressing the enter button we begin the meld process
                if ((Input.GetButtonDown(mySButton)))
                {
                    this.gameObject.transform.GetChild(2).forward = new Vector3((col.transform.position - transform.position).x, 0, (col.transform.position - transform.position).z);
                    anim.CrossFade("Meld");
                    melding        = true;
                    buttonPromptOn = false;
                }
                // otherwise, if they are in an object range and have gone through a meld animation, we transfer the player to the object
                else if (meldDone)
                {
                    //Play meld sound
                    soundSource.Stop();
                    soundSource.PlayOneShot(meld, 1.0f);

                    //Legacy animations dont support events on animation, so there is no way
                    //to make the animation play before this happens.
                    //Making this function an IEnumerator will break it as well

                    characterRenderer.enabled = false;
                    transform.GetComponent <Collider>().enabled = false;
                    if (Player1)
                    {
                        myCamera.GetComponent <CameraScript>().player1 = col.gameObject;
                    }
                    else
                    {
                        myCamera.GetComponent <CameraScript>().player2 = col.gameObject;
                    }

                    this.transform.position -= new Vector3(0, 100, 0);

                    meldDone = false;
                    if (Player1)
                    {
                        col.GetComponentInParent <EndObject>().player1 = this.gameObject;
                    }
                    else
                    {
                        col.GetComponentInParent <EndObject>().player2 = this.gameObject;
                    }
                }
            }

            if (transform.GetComponent <Collider>().enabled == false)
            {
                buttonPromptOn = false;
            }
        }
    }
Esempio n. 31
0
 public void Init(Color newColor, int orderId, int customerId)
 {
     OrderId    = orderId;
     CustomerId = customerId;
     ColorScript.SetColor(meshRenderer, newColor);
 }