Exemple #1
0
    void ControlBrokenChain()
    {
        if (brokenChainNodeDirty)
        {
            //brokenChainNodeDirty = false;
            if (brokenChainNodeSet.Count > 0)
            {
                int        maxIdx    = -1;
                int        max2ndIdx = -1;
                GameObject tailNode  = null;
                foreach (GameObject brokenNode in brokenChainNodeSet)
                {
                    int idx = balls.IndexOf(brokenNode);
                    if (idx > maxIdx)
                    {
                        tailNode  = brokenNode;
                        max2ndIdx = maxIdx;
                        maxIdx    = idx;
                    }
                }

                if (tailNode != null)
                {
                    float tailPercent = tailNode.GetComponent <BallChainMovement>().currPathPercent;
                    if (maxIdx + 1 >= balls.Count)
                    {
                        return;
                    }
                    GameObject tailBack = (GameObject)balls[maxIdx + 1];

                    float tailBackPercent = tailBack.GetComponent <BallChainMovement>().currPathPercent;
                    if (tailPercent - tailBackPercent < diameterPercent)
                    {
                        foreach (GameObject ball in balls.GetRange(max2ndIdx + 1, maxIdx - max2ndIdx))
                        {
                            ball.GetComponent <BallChainMovement>().moveFlag = true;
                        }
                        tailNode.GetComponent <BallChainMovement>().currPathPercent = tailBackPercent + diameterPercent;
                        brokenChainNodeSet.Remove(tailNode);
                        // TODO: register color check
                        CheckColorTableEntry entry = new CheckColorTableEntry();
                        entry.indexReference = maxIdx;
                        entry.covered        = false;
                        if (!checkColorTable.ContainsKey(tailNode))
                        {
                            checkColorTable.Add(tailNode, entry);
                        }
                    }
                    else
                    {
                        foreach (GameObject ball in balls.GetRange(max2ndIdx + 1, maxIdx - max2ndIdx))
                        {
                            ball.GetComponent <BallChainMovement>().moveFlag = false;
                        }
                    }
                }
            }
        }
    }
Exemple #2
0
	void UpdateInsertion () {
		// Move chain and Add bullet to chain
		int dequeSize = 0;
		foreach (MovementRegistrationEntry entry in insertionQueue) {
			if (Time.frameCount > entry.registerFrame) {
				// move all the leading balls
				foreach (GameObject ball in balls) {
					float deltaTime = Time.deltaTime;
					if (entry.proceedTime + deltaTime > insetionSmoothTime) {
						deltaTime = insetionSmoothTime - entry.proceedTime;
					}
					ball.GetComponent<BallChainMovement>()
						.PushFoward (diameterPercentPerSecond * deltaTime);
					if (ball == entry.chainBall) {
						break;
					}
				}

				entry.proceedTime += Time.deltaTime;

				// TODO: Fix the bug of position mismatch when multiple bullets
				// hit same chainBall
				if (entry.proceedTime > insetionSmoothTime) {
					dequeSize++;
					int idx = balls.IndexOf (entry.chainBall);
					if (entry.repeatChainBall > 1) {
						Debug.Log ("Same Time");
					}
					if (idx + entry.repeatChainBall >= balls.Count) {
						Debug.LogWarning ("Insertion idx Larger than chain size");
					}
					balls.Insert(idx + entry.repeatChainBall, entry.bulletBall);
					// Synchronizing the remove
					CheckColorTableEntry setEntry = new CheckColorTableEntry();
					setEntry.indexReference = idx + entry.repeatChainBall;
					setEntry.covered = false;
					if (!checkColorTable.ContainsKey(entry.bulletBall)) {
						checkColorTable.Add(entry.bulletBall, setEntry);
					}
					else {
						Debug.LogError ("Same bulletBall registered twice " + entry.bulletBall);
					}
					combo = 0;
					checkColorRegisterTime = Time.time;
					//Debug.Log (entry.bulletBall.name + " " + entry.chainBall.name + " " + (idx));
					entry.bulletBall.GetComponent<Rigidbody> ().isKinematic = false;
					entry.bulletBall.transform.parent = ballsObject.transform;
					BallChainMovement ballScript = entry.bulletBall
						.AddComponent <BallChainMovement>();
					ballScript.currPathPercent = entry.chainBall.GetComponent<BallChainMovement> ().currPathPercent
						- (entry.repeatChainBall) * diameterPercent;
					spawn.SetPPSForBallScript (ballScript);

				}
			}
			else {
				// as it is enqued in time order
				break;
			}
		}

		DequeHeadElements (dequeSize);

		// Move bullet
	}
Exemple #3
0
	void ControlBrokenChain () {
		if (brokenChainNodeDirty) {
			//brokenChainNodeDirty = false;
			if (brokenChainNodeSet.Count > 0) {
				int maxIdx = -1;
				int max2ndIdx = -1;
				GameObject tailNode = null;
				foreach (GameObject brokenNode in brokenChainNodeSet) {
					int idx = balls.IndexOf(brokenNode);
					if (idx > maxIdx) {
						tailNode = brokenNode;
						max2ndIdx = maxIdx;
						maxIdx = idx;
					}
				}

				if (tailNode != null) {
					float tailPercent = tailNode.GetComponent<BallChainMovement>().currPathPercent;
					if (maxIdx + 1 >= balls.Count) 
						return;
					GameObject tailBack = (GameObject)balls[maxIdx + 1];

					float tailBackPercent = tailBack.GetComponent<BallChainMovement>().currPathPercent;
					if (tailPercent - tailBackPercent < diameterPercent) {
						foreach (GameObject ball in balls.GetRange(max2ndIdx + 1, maxIdx - max2ndIdx)) {
							ball.GetComponent<BallChainMovement>().moveFlag = true;
						}
						tailNode.GetComponent<BallChainMovement>().currPathPercent = tailBackPercent + diameterPercent;
						brokenChainNodeSet.Remove(tailNode);
						// TODO: register color check
						CheckColorTableEntry entry = new CheckColorTableEntry();
						entry.indexReference = maxIdx;
						entry.covered = false;
						if (!checkColorTable.ContainsKey(tailNode))
							checkColorTable.Add (tailNode, entry);

					}
					else {
						foreach (GameObject ball in balls.GetRange(max2ndIdx + 1, maxIdx - max2ndIdx)) {
							ball.GetComponent<BallChainMovement>().moveFlag = false;
						}
					}
				}
			}
		}
	}
Exemple #4
0
    void UpdateInsertion()
    {
        // Move chain and Add bullet to chain
        int dequeSize = 0;

        foreach (MovementRegistrationEntry entry in insertionQueue)
        {
            if (Time.frameCount > entry.registerFrame)
            {
                // move all the leading balls
                foreach (GameObject ball in balls)
                {
                    float deltaTime = Time.deltaTime;
                    if (entry.proceedTime + deltaTime > insetionSmoothTime)
                    {
                        deltaTime = insetionSmoothTime - entry.proceedTime;
                    }
                    ball.GetComponent <BallChainMovement>()
                    .PushFoward(diameterPercentPerSecond * deltaTime);
                    if (ball == entry.chainBall)
                    {
                        break;
                    }
                }

                entry.proceedTime += Time.deltaTime;

                // TODO: Fix the bug of position mismatch when multiple bullets
                // hit same chainBall
                if (entry.proceedTime > insetionSmoothTime)
                {
                    dequeSize++;
                    int idx = balls.IndexOf(entry.chainBall);
                    if (entry.repeatChainBall > 1)
                    {
                        Debug.Log("Same Time");
                    }
                    if (idx + entry.repeatChainBall >= balls.Count)
                    {
                        Debug.LogWarning("Insertion idx Larger than chain size");
                    }
                    balls.Insert(idx + entry.repeatChainBall, entry.bulletBall);
                    // Synchronizing the remove
                    CheckColorTableEntry setEntry = new CheckColorTableEntry();
                    setEntry.indexReference = idx + entry.repeatChainBall;
                    setEntry.covered        = false;
                    if (!checkColorTable.ContainsKey(entry.bulletBall))
                    {
                        checkColorTable.Add(entry.bulletBall, setEntry);
                    }
                    else
                    {
                        Debug.LogError("Same bulletBall registered twice " + entry.bulletBall);
                    }
                    combo = 0;
                    checkColorRegisterTime = Time.time;
                    //Debug.Log (entry.bulletBall.name + " " + entry.chainBall.name + " " + (idx));
                    entry.bulletBall.GetComponent <Rigidbody> ().isKinematic = false;
                    entry.bulletBall.transform.parent = ballsObject.transform;
                    BallChainMovement ballScript = entry.bulletBall
                                                   .AddComponent <BallChainMovement>();
                    ballScript.currPathPercent = entry.chainBall.GetComponent <BallChainMovement> ().currPathPercent
                                                 - (entry.repeatChainBall) * diameterPercent;
                    spawn.SetPPSForBallScript(ballScript);
                }
            }
            else
            {
                // as it is enqued in time order
                break;
            }
        }

        DequeHeadElements(dequeSize);

        // Move bullet
    }