本文整理汇总了C#中Shape.Assign方法的典型用法代码示例。如果您正苦于以下问题:C# Shape.Assign方法的具体用法?C# Shape.Assign怎么用?C# Shape.Assign使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shape
的用法示例。
在下文中一共展示了Shape.Assign方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindMatchesAndCollapse
private IEnumerator FindMatchesAndCollapse(RaycastHit2D hit2)
{
//get the second item that was part of the swipe
var hitGo2 = hit2.collider.gameObject;
shapes.Swap(hitGo, hitGo2);
//move the swapped ones
hitGo.transform.positionTo(Constants.AnimationDuration, hitGo2.transform.position);
hitGo2.transform.positionTo(Constants.AnimationDuration, hitGo.transform.position);
yield return new WaitForSeconds(Constants.AnimationDuration);
//get the matches via the helper methods
var hitGomatchesInfo = shapes.GetMatches(hitGo);
var hitGo2matchesInfo = shapes.GetMatches(hitGo2);
var totalMatches = hitGomatchesInfo.MatchedCandy
.Union(hitGo2matchesInfo.MatchedCandy).Distinct();
//if user's swap didn't create at least a 3-match, undo their swap
if (totalMatches.Count() < Constants.MinimumMatches)
{
hitGo.transform.positionTo(Constants.AnimationDuration, hitGo2.transform.position);
hitGo2.transform.positionTo(Constants.AnimationDuration, hitGo.transform.position);
yield return new WaitForSeconds(Constants.AnimationDuration);
shapes.UndoSwap();
}
//if more than 3 matches and no Bonus is contained in the line, we will award a new Bonus
bool addBonus = totalMatches.Count() >= Constants.MinimumMatchesForBonus &&
!BonusTypeUtilities.ContainsDestroyWholeRowColumn(hitGomatchesInfo.BonusesContained) &&
!BonusTypeUtilities.ContainsDestroyWholeRowColumn(hitGo2matchesInfo.BonusesContained);
Shape hitGoCache = null;
if (addBonus)
{
hitGoCache = new Shape();
//get the game object that was of the same type
var sameTypeGo = hitGomatchesInfo.MatchedCandy.Count() > 0 ? hitGo : hitGo2;
var shape = sameTypeGo.GetComponent<Shape>();
//cache it
hitGoCache.Assign(shape.Type, shape.Row, shape.Column);
}
int timesRun = 1;
while (totalMatches.Count() >= Constants.MinimumMatches)
{
//increase score
IncreaseScore((totalMatches.Count() - 2) * Constants.Match3Score);
if (timesRun >= 2)
IncreaseScore(Constants.SubsequentMatchScore);
soundManager.PlayCrincle();
foreach (var item in totalMatches)
{
shapes.Remove(item);
RemoveFromScene(item);
}
//check and instantiate Bonus if needed
if (addBonus)
CreateBonus(hitGoCache);
addBonus = false;
//get the columns that we had a collapse
var columns = totalMatches.Select(go => go.GetComponent<Shape>().Column).Distinct();
//the order the 2 methods below get called is important!!!
//collapse the ones gone
var collapsedCandyInfo = shapes.Collapse(columns);
//create new ones
var newCandyInfo = CreateNewCandyInSpecificColumns(columns);
int maxDistance = Mathf.Max(collapsedCandyInfo.MaxDistance, newCandyInfo.MaxDistance);
MoveAndAnimate(newCandyInfo.AlteredCandy, maxDistance);
MoveAndAnimate(collapsedCandyInfo.AlteredCandy, maxDistance);
//will wait for both of the above animations
yield return new WaitForSeconds(Constants.MoveAnimationMinDuration * maxDistance);
//search if there are matches with the new/collapsed items
totalMatches = shapes.GetMatches(collapsedCandyInfo.AlteredCandy).
Union(shapes.GetMatches(newCandyInfo.AlteredCandy)).Distinct();
timesRun++;
}
state = GameState.None;
StartCheckForPotentialMatches();
}
示例2: FindMatchesAndCollapse
private IEnumerator FindMatchesAndCollapse(RaycastHit2D hit2)
{
// Get the second item that was part of the swipe
var hitGo2 = hit2.collider.gameObject;
shapes.Swap(hitGo, hitGo2);
// Move the swapped ones
hitGo.transform.positionTo(Constants.AnimationDuration, hitGo2.transform.position);
hitGo2.transform.positionTo(Constants.AnimationDuration, hitGo.transform.position);
yield return new WaitForSeconds(Constants.AnimationDuration);
// Get the matches via the helper methods
var hitGoMatchesInfo = shapes.GetMatches(hitGo);
var hitGo2MatchesInfo = shapes.GetMatches(hitGo2);
var totalMatches = hitGoMatchesInfo.MatchedGlyph.Union(hitGo2MatchesInfo.MatchedGlyph).Distinct();
// If the swap did not create at least a 3-match, undo the swap
if (totalMatches.Count() < Constants.MinimumMatches)
{
hitGo.transform.positionTo(Constants.AnimationDuration, hitGo2.transform.position);
hitGo2.transform.positionTo(Constants.AnimationDuration, hitGo.transform.position);
yield return new WaitForSeconds(Constants.AnimationDuration);
shapes.UndoSwap();
}
// If more than 3 matches and no Bonus is contained in the line, award a new Bonus
bool addBonus = totalMatches.Count() >= Constants.MinimumMatchesForBonus &&
!BonusTypeUtilities.ContainsDestroyWholeRowColumn(hitGoMatchesInfo.BonusesContained) &&
!BonusTypeUtilities.ContainsDestroyWholeRowColumn(hitGo2MatchesInfo.BonusesContained);
Shape hitGoCache = null;
if (addBonus)
{
hitGoCache = new Shape();
// Get the game object that was of the same type
var sameTypeGo = hitGoMatchesInfo.MatchedGlyph.Count() > 0 ? hitGo : hitGo2;
var shape = sameTypeGo.GetComponent<Shape>();
// Cache the game object
hitGoCache.Assign(shape.Type, shape.Row, shape.Column);
}
int timesRun = 1;
bool validTurn = false;
while (totalMatches.Count() >= Constants.MinimumMatches)
{
// Increase score
IncreaseScore((totalMatches.Count() - 2) * Constants.Match3Score);
if (timesRun >= 2)
{
IncreaseScore(Constants.SubsequentMatchScore);
}
// Set turn as valid
if (totalMatches.Count() >= 3)
{
validTurn = true;
}
foreach (var item in totalMatches)
{
shapes.Remove(item);
RemoveFromScene(item);
}
// Check and instantiate Bonus if needed
if (addBonus)
{
CreateBonus(hitGoCache);
}
addBonus = false;
// Get the columns that have a collapse
var columns = totalMatches.Select(go => go.GetComponent<Shape>().Column).Distinct();
// The order the two methods below get called is important
// Collapse the ones gone
var collapsedGlyphInfo = shapes.Collapse(columns);
// Create new ones
var newGlyphInfo = CreateNewGlyphsInSpecificColumns(columns);
int maxDistance = Mathf.Max(collapsedGlyphInfo.MaxDistance, newGlyphInfo.MaxDistance);
MoveAndAnimate(newGlyphInfo.AlteredGlyph, maxDistance);
MoveAndAnimate(collapsedGlyphInfo.AlteredGlyph, maxDistance);
// Wait for both of the above animations
yield return new WaitForSeconds(Constants.MoveAnimationMinDuration * maxDistance);
// Search if there are matches with the new/collapsed items
totalMatches = shapes.GetMatches(collapsedGlyphInfo.AlteredGlyph).
Union(shapes.GetMatches(newGlyphInfo.AlteredGlyph)).Distinct();
//.........这里部分代码省略.........