예제 #1
0
        public void StopGeneration()
        {
            IsRunning = false;

            Destroy(_currentShapeObj);
            _currentSymbolSet = null;
        }
예제 #2
0
        public void StartGeneration()
        {
            if (IsRunning)
            {
                return;
            }

            Debug.Log("[RandomShapeGeneration] Start");

            IsRunning = true;

            _currentSymbolSet = GenerateNewSymbol();
            _currentShapeObj  = InstantiateSymbolSet(_currentSymbolSet);
        }
예제 #3
0
        private GameObject InstantiateSymbolSet(GameBehaviour.SymbolSet symbolSet)
        {
            GameObject go = new GameObject {
                name = "Shape"
            };
            MeshRenderer r = go.AddComponent <MeshRenderer>();

            go.AddComponent <MeshFilter>().mesh = symbolSet.Symbol.Mesh;
            r.material = _shapeMaterial;
            Material m = r.material;

            m.SetColor("_EmissionColor", GetColor(symbolSet.Color));

            go.transform.SetParent(transform);
            go.transform.localScale    = Vector3.one;
            go.transform.localPosition = Vector3.zero;
            return(go);
        }
예제 #4
0
        public void CheckPlayerEntry(int id, GameBehaviour.SymbolSet entry)
        {
            if (_currentSymbolSet == null)
            {
                return;
            }

            // Good
            //
            if (_currentSymbolSet.Symbol.Type == entry.Symbol.Type && _currentSymbolSet.Color == entry.Color)
            {
                _audioSource.clip = _goodClip;

                if (id == 0)
                {
                    GameBehaviour.Instance.ScorePlayer1 += POINT_SCORE;
                    GameBehaviour.Instance.PlatformPlayer1.GoodFlash();
                }
                else
                {
                    GameBehaviour.Instance.ScorePlayer2 += POINT_SCORE;
                    GameBehaviour.Instance.PlatformPlayer2.GoodFlash();
                }

                Destroy(_currentShapeObj);
                _currentSymbolSet = GenerateNewSymbol();
                _currentShapeObj  = InstantiateSymbolSet(_currentSymbolSet);

                _nbSuccess++;

                if (_nbSuccess == 5)
                {
                    if (id == 0)
                    {
                        GameBehaviour.Instance.ScorePlayer1 += BONUS_SCORE;
                    }
                    else
                    {
                        GameBehaviour.Instance.ScorePlayer2 += BONUS_SCORE;
                    }
                }
            }
            // Wrong
            //
            else
            {
                _audioSource.clip = _wrongClip;

                if (id == 0)
                {
                    GameBehaviour.Instance.ScorePlayer1 -= ERROR_SCORE;
                    GameBehaviour.Instance.PlatformPlayer1.WrongFlash();
                }
                else
                {
                    GameBehaviour.Instance.ScorePlayer2 -= ERROR_SCORE;
                    GameBehaviour.Instance.PlatformPlayer2.WrongFlash();
                }

                _nbSuccess = 0;
            }

            _audioSource.Play();
        }