public void OnGeneralDead(WhichSide side) { state = State.Dead; Time.timeScale = 0.5f; if (side == WhichSide.Left) { rightGeneral.SetIdle(); SetCameraMoveTo(leftGeneral.transform.localPosition); for (int i = 0; i < leftSoliders.Count; i++) { leftSoliders[i].SetEscape(); } } else { leftGeneral.SetIdle(); SetCameraMoveTo(rightGeneral.transform.localPosition); for (int i = 0; i < rightSoliders.Count; i++) { rightSoliders[i].SetEscape(); } } SoundController.Instance.PlaySound("00023"); }
public SolidersController GetRandomSolider(WhichSide side) { if (side == WhichSide.Left) { if (leftSoliders.Count > 0) { return(leftSoliders[Random.Range(0, leftSoliders.Count)]); } else { return(null); } } else { if (rightSoliders.Count > 0) { return(rightSoliders[Random.Range(0, rightSoliders.Count)]); } else { return(null); } } }
public void CheckGesture() { _lastFrame = _leap_controller.Frame(0); tFrame = _leap_controller.Frame(5); Hands = _lastFrame.Hands; foreach (Hand hand in Hands) { tempHand = hand; Fingers = hand.Fingers; if (WhichSide.IsEnableGestureHand(this) && WhichSide.IsEnableGestureHand(this) && WhichSide.capturedSide(hand, _useArea, _mountType)) { this._isChecked = GestureCondition(); if (this._isChecked) { break; } } } if (_isChecked) { DoAction(); } }
public bool OnSoliderHitChecking(WhichSide side, int type, Direction dir, int range, int xPos, int yPos) { bool flag = false; int xS = 0; int xE = 0; if (dir == Direction.Left) { xS = xPos - range; xE = xPos; } else { xS = xPos; xE = xPos + range; } for (int i = xS; i <= xE; i++) { if (GetLocationIsEnemy(side, i, yPos)) { flag = true; break; } } if (!flag) { return(false); } CheckDamage(side, 2, 1, type, dir, xS, xE, yPos, false); return(true); }
/// <summary> /// map out a route from shape1 to shape2, starting from a specific side of shape1. /// </summary> /// <param name="InCanvas"></param> /// <param name="Shape1"></param> /// <param name="Shape2"></param> /// <param name="DepartureSide"></param> /// <param name="Route"></param> public static void DrawRouteBetweenShapes( this Canvas InCanvas, Shape Shape1, Shape Shape2, WhichSide DepartureSide, ConnectionRoute Route) { // vertical and horizontal intersection of the two shapes. var vi = ShapeExt.VerticalIntersect(Shape1, Shape2); var hi = ShapeExt.HorizontalIntersect(Shape1, Shape2); if (DepartureSide == WhichSide.Left) { LineCoordinates coor = null; if (Shape1.IsEntirelyToTheRightOf(Shape2).GetValueOrDefault() && (vi.Length > 0)) { coor = InCanvas.DrawLineBetweenShapes( Shape1, WhichSide.Left, Shape2, WhichSide.Right); } else { // draw a short line from the shape to the next available orbit location // around the from shape. var leg = ConnectionLeg.DrawLegToOrbit(Shape1, DepartureSide); Route.AddLeg(leg); } } }
public static LineCoordinates GetSide(this Rectangle Rect, WhichSide Side) { var left = Canvas.GetLeft(Rect); var right = left + Rect.ActualWidth - 1.00; var top = Canvas.GetTop(Rect); var bottom = top + Rect.ActualHeight - 1.00; switch (Side) { case WhichSide.Left: return(new LineCoordinates(new Point(left, top), new Point(left, bottom))); case WhichSide.Right: return(new LineCoordinates(new Point(right, top), new Point(right, bottom))); case WhichSide.Top: return(new LineCoordinates(new Point(left, top), new Point(right, top))); case WhichSide.Bottom: return(new LineCoordinates(new Point(left, bottom), new Point(right, bottom))); default: throw new ApplicationException("unsupported enum value"); } }
/// <summary> /// Return a ConnectionLeg which contains draw instructions for a line that runs /// from the DepartureSide of a shape to the location of the orbit that runs /// around the shape. /// </summary> /// <param name="FromShape"></param> /// <param name="DepartureSide"></param> /// <returns></returns> public static ConnectionLeg DrawLegToOrbit(Shape FromShape, WhichSide DepartureSide) { var sideCoor = FromShape.GetSide(DepartureSide); var midPt = sideCoor.MidPoint; double lgthToOrbit = 30; ConnectionLeg leg = null; // draw line depending on the side of the shape. LineCoordinates legCoor = null; var whichDir = DepartureSide.ToDirection(); legCoor = new LineCoordinates(midPt, new LineVector(lgthToOrbit, whichDir)); // line is off the canvas. do not create a connection leg. if ((legCoor.Start.X < 0) || (legCoor.Start.Y < 0) || (legCoor.End.X < 0) || (legCoor.End.Y < 0)) { leg = null; } else { leg = new ConnectionLeg() { Start = midPt, LineCoor = legCoor, Direction = whichDir }; } return(leg); }
public static bool IsOppositeDirection( this Shape FromShape, WhichDirection Direction, Shape ToShape) { WhichSide side = Direction.ToSide(); if (side == WhichSide.Left) { if ( FromShape } switch (side) { case WhichDirection.Down: break; case WhichDirection.Up: break; case WhichDirection.Left: break; case WhichDirection.Right: break; default: throw new ApplicationException("unexpected direction"); } return side; }
public ReportColDefn(string ColName, int Width = 0, WhichSide WhichSide = WhichSide.Left) { this.ColName = ColName; this.ColHead = new string[] { this.ColName }; this.Width = Width; this.WhichSide = WhichSide; }
public static ConnectionRoute StartConnectionRouteToShape( Shape FromShape, WhichSide StartSide, Shape ToShape) { var fromSide = new ShapeSide(FromShape, StartSide); ConnectionRoute route = new ConnectionRoute(fromSide, ToShape); return(route); }
public void SetGeneralAssault(WhichSide side) { if (side == WhichSide.Left) { leftGeneral.SetRun(); } else { rightGeneral.SetRun(); } }
public void AddBackSolider(WhichSide side, SolidersController sCtrl) { if (side == WhichSide.Left) { leftBackSoliders.Add(sCtrl); } else { rightBackSoliders.Add(sCtrl); } }
public bool IsSwordFull(WhichSide side) { if (side == WhichSide.Left) { return(isLeftSwordFull); } else { return(isRightSwordFull); } }
public bool OnMagicHitChecking(WhichSide side, int gDamage, Rect region, bool isFire) { Direction dir = (Direction)Random.Range(0, 2); int xS = GetLocationPositionX(region.x); int xE = GetLocationPositionX(region.x + region.width); int yS = GetLocationPositionY(region.y); int yE = GetLocationPositionY(region.y + region.height); for (int yPos = yS; yPos <= yE; yPos++) { CheckDamage(side, gDamage, -1, -1, dir, xS, xE, yPos, isFire); } return(true); }
bool CheckDamage(WhichSide side, int gDamage, int gType, int type, Direction dir, int xS, int xE, int yPos, bool isFire) { int x = 0; int y = 0; if (side == WhichSide.Right) { for (int i = 0; i < leftSoliders.Count; i++) { x = leftSoliders[i].GetLocationX(); y = leftSoliders[i].GetLocationY(); if (y == yPos && x >= xS && x <= xE) { leftSoliders[i].OnDamage(type, dir, isFire); } } x = GetLocationPositionX(leftGeneral.transform.localPosition.x); y = GetLocationPositionY(leftGeneral.transform.localPosition.y); if (y == yPos && x >= xS && x <= xE) { leftGeneral.OnDamage(gDamage, gType, isFire); } } else { for (int i = 0; i < rightSoliders.Count; i++) { x = rightSoliders[i].GetLocationX(); y = rightSoliders[i].GetLocationY(); if (y == yPos && x >= xS && x <= xE) { rightSoliders[i].OnDamage(type, dir, isFire); } } x = GetLocationPositionX(rightGeneral.transform.localPosition.x); y = GetLocationPositionY(rightGeneral.transform.localPosition.y); if (y == yPos && x >= xS && x <= xE) { rightGeneral.OnDamage(gDamage, gType, isFire); } } return(false); }
public void SetFrontArmyBack(WhichSide side) { if (side == WhichSide.Left) { for (int i = 0; i < leftFrontSoliders.Count; i++) { leftFrontSoliders[i].SetMovingBack(); } } else { for (int i = 0; i < rightFrontSoliders.Count; i++) { rightFrontSoliders[i].SetMovingBack(); } } }
public void SetSoldierMagicLock(WhichSide side) { if (side == WhichSide.Left) { for (int i = 0; i < leftSoliders.Count; i++) { leftSoliders[i].SetOnMagicLock(); } } else { for (int i = 0; i < rightSoliders.Count; i++) { rightSoliders[i].SetOnMagicLock(); } } }
public static LineCoordinates DrawLineBetweenShapes( this Canvas InCanvas, Shape Shape1, WhichSide WhichSide1, Shape Shape2, WhichSide WhichSide2) { LineCoordinates betLine = null; var coor1 = Shape1.GetSide(WhichSide1); var coor2 = Shape2.GetSide(WhichSide2); // line runs from the midpoint of one side to the mid point of the other. betLine = new LineCoordinates(coor1.MidPoint, coor2.MidPoint); // draw a vertical line between the shapes. if ((WhichSide1 == WhichSide.Bottom) && (WhichSide2 == WhichSide.Top)) { var hi = LineCoordinates.HorizontalIntersect(coor1, coor2); if (hi.Length > 0) { double centeredIntersect1 = hi.Line1Ofs + (hi.Length / 2); Point fromPt = coor1.CalcHorizontalPointOnLine(centeredIntersect1); double centeredIntersect2 = hi.Line2Ofs + (hi.Length / 2); Point toPt = coor2.CalcHorizontalPointOnLine(centeredIntersect2); betLine = new LineCoordinates(fromPt, toPt); } } // draw a horizontal line between the shapes. else if ((WhichSide1 == WhichSide.Right) && (WhichSide2 == WhichSide.Left)) { var vi = LineCoordinates.VerticalIntersect(coor1, coor2); if (vi.Length > 0) { double centeredIntersect1 = vi.Line1Ofs + (vi.Length / 2); Point fromPt = coor1.CalcVerticalPointOnLine(centeredIntersect1); double centeredIntersect2 = vi.Line2Ofs + (vi.Length / 2); Point toPt = coor2.CalcVerticalPointOnLine(centeredIntersect2); betLine = new LineCoordinates(fromPt, toPt); } } // get horizontal intersect between the two lines // return the intersect as from and to pos, // get center pos of the horizontal intersect return(betLine); }
public bool GetLocationIsEnemy(WhichSide s, int x, int y) { if (locationFlag[x, y] == 0) { return(false); } if (s == WhichSide.Left && locationFlag[x, y] > 0) { return(true); } else if (s == WhichSide.Right && locationFlag[x, y] < 0) { return(true); } return(false); }
public static WhichDirection ToDirection(this WhichSide Side) { switch (Side) { case WhichSide.Bottom: return(WhichDirection.Down); case WhichSide.Top: return(WhichDirection.Up); case WhichSide.Left: return(WhichDirection.Left); case WhichSide.Right: return(WhichDirection.Right); default: throw new ApplicationException("unexpected side"); } }
public virtual void CheckGesture() { this._lastFrame = this._leap_controller.Frame(0); this.Hands = this._lastFrame.Hands; this._gestures = this._lastFrame.Gestures(); foreach (Hand hand in Hands) { tempHand = hand; _fingers = hand.Fingers; if (WhichSide.IsEnableGestureHand(this)) { this._fingers = hand.Fingers; foreach (Gesture gesture in _gestures) { if ((gesture.Type == Gesture.GestureType.TYPE_KEY_TAP) && WhichSide.capturedSide(hand, _useArea, _mountType)) { _keytab_gesture = new KeyTapGesture(gesture); this.GetDirection(); this.GetPointable(); this.GestureInvokePosition(); this._isChecked = true; break; } } } if (this._isChecked) { break; } } if (this._isChecked) { DoAction(); } }
public void SetArmyEscape(WhichSide side) { if (side == WhichSide.Left) { leftGeneral.SetEscape(); for (int i = 0; i < leftSoliders.Count; i++) { leftSoliders[i].SetEscape(); } } else { rightGeneral.SetEscape(); for (int i = 0; i < rightSoliders.Count; i++) { rightSoliders[i].SetEscape(); } } }
public void SetIsSwordFull(WhichSide side, bool flag) { if (side == WhichSide.Left) { isLeftSwordFull = flag; if (!isLeftSwordFull) { infoPanel.ResetSwordValue(WhichSide.Left); } } else { isRightSwordFull = flag; if (!isRightSwordFull) { infoPanel.ResetSwordValue(WhichSide.Right); } } }
public Vector3 GetArmyCentrePoint(WhichSide side) { Vector3 ret = Vector3.zero; Vector3 sum = new Vector3(0, 0, 0); if (side == WhichSide.Left) { if (leftSoliders.Count > 0) { for (int i = 0; i < leftSoliders.Count; i++) { sum += leftSoliders[i].transform.localPosition; } ret = sum / leftSoliders.Count; } else { ret = leftGeneral.transform.localPosition; } } else { if (rightSoliders.Count > 0) { for (int i = 0; i < rightSoliders.Count; i++) { sum += rightSoliders[i].transform.localPosition; } ret = sum / rightSoliders.Count; } else { ret = rightGeneral.transform.localPosition; } } ret.z = 0; return(ret); }
public void OnWarResult(WhichSide s, bool isEscape) { OnPauseGame(); if (state == State.Magic) { MagicController.Instance.OnMagicOver(); } state = State.End; loser = s; WarSceneController.isEscape = isEscape; string text = ""; if (!isEscape) { text = ZhongWen.Instance.shengli1[Random.Range(0, 7)]; } else { text = ZhongWen.Instance.shengli2[Random.Range(0, 5)]; } if (loser == WhichSide.Left) { dialog.SetDialogue(text, WhichSide.Right); SetCameraMoveTo(rightGeneral.transform.localPosition); SoundController.Instance.PlaySound("00047"); } else if (loser == WhichSide.Right) { dialog.SetDialogue(text, WhichSide.Left); SetCameraMoveTo(leftGeneral.transform.localPosition); SoundController.Instance.PlaySound("00046"); } }
public virtual void CheckGesture() { _lastFrame = _leap_controller.Frame(); Hands = _lastFrame.Hands; foreach (Hand hand in Hands) { tempHand = hand; if (WhichSide.IsEnableGestureHand(this) && WhichSide.capturedSide(hand, _useArea, _mountType) && IsCorrectHandDirection(hand)) { this._isChecked = true; break; } } if (this._isChecked) { DoAction(); } }
public void SetArmyAssault(WhichSide side) { if (side == WhichSide.Left) { for (int i = 0; i < leftSoliders.Count; i++) { leftSoliders[i].SetRun(); } leftGeneral.SetArmyAssault(); SetCameraMoveTo(new Vector3(leftGeneral.transform.localPosition.x, leftGeneral.transform.localPosition.y - 30, 0)); } else { for (int i = 0; i < rightSoliders.Count; i++) { rightSoliders[i].SetRun(); } rightGeneral.SetArmyAssault(); SetCameraMoveTo(new Vector3(rightGeneral.transform.localPosition.x, rightGeneral.transform.localPosition.y - 30, 0)); } state = State.Assault; step = 0; isMouseDown = true; isMouseMove = false; dialog.SetDialogue(ZhongWen.Instance.quanjuntuji, side); dialog.gameObject.SetActive(false); OnPauseGame(); SoundController.Instance.PlaySound("00053"); }
public bool IsEnableGestureHand() { return(WhichSide.IsEnableGestureHand(this)); }
public void AddColDefn(string ColName, int Width = 0, WhichSide WhichSide = WhichSide.Left) { var colDefn = new ReportColDefn(ColName, Width, WhichSide); this.ColDefn.Add(colDefn); }
public ShapeSide(Shape Shape, WhichSide WhichSide) { this.Shape = Shape; this.WhichSide = WhichSide; }