Пример #1
0
    // Update is called once per frame
    void Update()
    {
        if (GamePlayManager.CurGameState != GamePlayManager.GameState.InGame)
        {
            return;
        }
        //catch input information
        if (Input.GetKeyDown(fireKey))
        {
            isOn = !isOn;
            playerMeshRenderer.material.color = (isOn)? GeneralTable.GetColor(type) : GeneralTable.GetColor(GeneralTable.Type.White);
            if (isOn)
            {
                EnType();
            }
            else
            {
                DeType();
            }
        }

        if (Input.GetKeyDown(changeDirKey) && isOn)
        {
            ChangeWaypointColor();
        }
    }
Пример #2
0
    private void OnTriggerEnter(Collider other)
    {
        ColorBall tempColorBall = other.gameObject.GetComponent <ColorBall>();

        if (tempColorBall)
        {
            // Don't case equal for now lol
            if ((int)type > (int)tempColorBall.type)
            {
                type      = GeneralTable.Combine(type, tempColorBall.type);
                BallColor = GeneralTable.GetColor(type);

                GamePlayManager.Instance.centerPoint.RemoveEstimateColorBallNum();
            }
            else
            {
                Destroy(this.gameObject);
            }
        }
        CenterPoint tempCenterPoint = other.gameObject.GetComponent <CenterPoint>();

        if (tempCenterPoint)
        {
            nextCenterPoint.match(type);
            ballCollider.enabled = false;
        }
    }
Пример #3
0
    // if Color match queue color, add one point, and create another color into queue.
    public bool match(GeneralTable.Type typeValue)
    {
        currentColorBallNum++;

        bool result = false;

        if (!typeValue.Equals(targetTypeQueue.Peek()))
        {
            failFlag = true;
            result   = true;
        }

        if (currentColorBallNum == estimateColorBallNum)
        {
            GamePlayManager.Instance.ResetTimer();
            if (failFlag)
            {
                PerformFail();
            }
            else
            {
                currentPoint++;
                GamePlayManager.Instance.NextStage();
                GeneralTable.Type currentType = targetTypeQueue.Peek();
                while (currentType == targetTypeQueue.Peek())
                {
                    targetTypeQueue.Dequeue();
                    targetTypeQueue.Enqueue(GeneralTable.GetRandomType());
                }
                centerPointMeshRenderer.material.color = GeneralTable.GetColor(targetTypeQueue.Peek());
            }
        }

        return(result);
    }
Пример #4
0
 public void DeType(GeneralTable.Type type)
 {
     myType = GeneralTable.Remove(myType, type);
     waypointMeshRenderer.material.color = GeneralTable.GetColor(myType);
     if (colorLine)
     {
         colorLine.RemoveType(type);
     }
     if (colorLines.Length > 0)
     {
         colorLines[nextWaypointIndex].RemoveType(type);
     }
 }
Пример #5
0
    void OnGameOver()
    {
        if (startWaypoint.nextWaypointIndex != 0)
        {
            ChangeWaypointColor();
        }

        if (!isOn)
        {
            EnType();
        }
        isOn = true;
        playerMeshRenderer.material.color = GeneralTable.GetColor(type);
    }
Пример #6
0
    public void FireColorBall()
    {
        if (ps)
        {
            ps.Clear();
            //ps.startColor = GeneralTable.GetColor(type);
            ps.Play();
        }

        GameObject colorballGO = Instantiate(colorBallRef);

        colorballGO.transform.position = new Vector3(this.transform.position.x, 1, this.transform.position.z);
        colorballGO.GetComponent <ColorBall>().type         = type;
        colorballGO.GetComponent <ColorBall>().BallColor    = GeneralTable.GetColor(type);
        colorballGO.GetComponent <ColorBall>().nextWaypoint = startWaypoint;
    }
Пример #7
0
    public void Reset()
    {
        currentPoint = 0;

        blackFlag      = false;
        cumulativeTime = 0;

        estimateColorBallNum = 0;
        currentColorBallNum  = 0;
        failFlag             = false;

        targetTypeQueue.Clear();
        for (int i = 0; i < countMax; ++i)
        {
            targetTypeQueue.Enqueue(GeneralTable.GetRandomType());
        }
        centerPointMeshRenderer.material.color = GeneralTable.GetColor(targetTypeQueue.Peek());

        this.transform.localScale = new Vector3(fixedScale, fixedScale, fixedScale);
    }
Пример #8
0
 public void Start()
 {
     colorLineRenderer.material.color = GeneralTable.GetColor(colorType);
 }
Пример #9
0
 public void RemoveType(GeneralTable.Type type)
 {
     colorType = GeneralTable.Remove(type, colorType);
     colorLineRenderer.material.color = GeneralTable.GetColor(colorType);
 }
Пример #10
0
 public void AddType(GeneralTable.Type type)
 {
     colorType = GeneralTable.Combine(type, colorType);
     colorLineRenderer.material.color = GeneralTable.GetColor(colorType);
 }
Пример #11
0
 void init()
 {
     GamePlayManager.OnGameOver += OnGameOver;
     //keep and do something
     playerMeshRenderer.material.color = GeneralTable.GetColor(type);
 }
Пример #12
0
 private void Update()
 {
     if (blackFlag)
     {
         cumulativeTime += Time.deltaTime;
         centerPointMeshRenderer.material.color = Color.Lerp(centerPointMeshRenderer.material.color, GeneralTable.GetColor(GeneralTable.Type.White), cumulativeTime / colorLerpPeriod);
         if (cumulativeTime / colorLerpPeriod >= 1)
         {
             blackFlag = false;
         }
     }
 }
Пример #13
0
 // Use this for initialization
 void Start()
 {
     Reset();
     GamePlayManager.OnGameStart           += Reset;
     centerPointMeshRenderer.material.color = GeneralTable.GetColor(GeneralTable.Type.White);
 }