internal HDXElement ConvertABS() { HDXElement ret = new HDXElement(); if (Type != HDXMethod.TGF) { return(this); } else { List <HDXData> newLeftLine = new List <HDXData>(); for (int i = 0; i < LeftLine.Count; i++) { var range = LeftLine.GetRange(0, i + 1); newLeftLine.Add(new HDXData((from a in range select a.x).ToList().Sum(), (from a in range select a.h).ToList().Sum())); } ret.LeftLine = newLeftLine; List <HDXData> newRightLine = new List <HDXData>(); for (int i = 0; i < RightLine.Count; i++) { var range = RightLine.GetRange(0, i + 1); newRightLine.Add(new HDXData((from a in range select a.x).ToList().Sum(), (from a in range select a.h).ToList().Sum())); } ret.RightLine = newRightLine; ret.Type = HDXMethod.ABS; ret.PK = PK; return(ret); } }
//Bullet colitions private void OnTriggerEnter2D(Collider2D otherCollider) { LeftLine myLeftLine = otherCollider.gameObject.GetComponent <LeftLine>(); //get the sidelines RightLine myRightLine = otherCollider.gameObject.GetComponent <RightLine>(); //get the sidelines BottomLine myBottomline = otherCollider.gameObject.GetComponent <BottomLine>(); //get the Bottomline PlayerScript myPlayer = otherCollider.gameObject.GetComponent <PlayerScript>(); //get the Player EnemyScript myEnemy = otherCollider.gameObject.GetComponent <EnemyScript>(); //get the STD //if the collliding object is any sideline //if the collliding object is any sideline if (myRightLine != null) { MyAudioManager.BallBounce(); if (MovingStuffVelocity.x > 0) { MovingStuffVelocity.x *= -1; } MovingStuffVelocity = new Vector2(MovingStuffVelocity.x, MovingStuffVelocity.y); MovingStuffRB.velocity = MovingStuffVelocity; //STDBallSpeedX *= -1; } //if the collliding object is bottomline if (myLeftLine != null) { MyAudioManager.BallBounce(); if (MovingStuffVelocity.x < 0) { MovingStuffVelocity.x *= -1; } MovingStuffVelocity = new Vector2(MovingStuffVelocity.x, MovingStuffVelocity.y); MovingStuffRB.velocity = MovingStuffVelocity; //STDBallSpeedX *= -1; } //if the collliding object is bottomline else if (myBottomline != null) { transform.position = PointOutSideScreen; //bullet disappears MoveStdBullet = false; //StopBulletMovement myBlinkerTextObject.transform.position = PointOutSideScreen; //transform condom blinking text MyBlinkerCounter = 0; } else if (myPlayer != null) { MoveStdBullet = false; //StopBulletMovement transform.position = PointOutSideScreen; //bullet disappears //do stuff myPlayer.transform.localScale = new Vector2(PlayerScript.PlayerObjectSize.x / 2f, PlayerScript.PlayerObjectSize.y / 2f); //reduce player size by 50% PlayerScript.SharpCondomsPlayerSizeCounter = 1; //initiate the playersize counter StdPongPlayScript.intCurrentPlayerScore -= 3; //reduce player points myBlinkerTextObject.transform.position = PointOutSideScreen; //transform condom blinking text MyBlinkerCounter = 0; } }
/// <summary> /// Draw the border using draw event arguments and specified bounding rectangle. /// </summary> /// <param name="e">Draw event arguments.</param> /// <param name="rect">Bounding rectangle.</param> /// <remarks> /// This method is for internal use only. /// </remarks> public void Draw(FRPaintEventArgs e, RectangleF rect) { IGraphics g = e.Graphics; rect.X *= e.ScaleX; rect.Y *= e.ScaleY; rect.Width *= e.ScaleX; rect.Height *= e.ScaleY; if (Shadow) { //int d = (int)Math.Round(ShadowWidth * e.ScaleX); //Pen pen = e.Cache.GetPen(ShadowColor, d, DashStyle.Solid); //g.DrawLine(pen, rect.Right + d / 2, rect.Top + d, rect.Right + d / 2, rect.Bottom); //g.DrawLine(pen, rect.Left + d, rect.Bottom + d / 2, rect.Right + d, rect.Bottom + d / 2); float d = ShadowWidth * e.ScaleX; Brush brush = e.Cache.GetBrush(ShadowColor); g.FillRectangle(brush, rect.Left + d, rect.Bottom, rect.Width, d); g.FillRectangle(brush, rect.Right, rect.Top + d, d, rect.Height); } if (Lines != BorderLines.None) { // draw full frame as a rectangle with solid line only. Non-solid lines // should be drawn separately to avoid overlapping effect if (Lines == BorderLines.All && LeftLine.Equals(TopLine) && LeftLine.Equals(RightLine) && LeftLine.Equals(BottomLine) && LeftLine.Style == LineStyle.Solid) { Pen pen = e.Cache.GetPen(LeftLine.Color, (int)Math.Round(LeftLine.Width * e.ScaleX), LeftLine.DashStyle); g.DrawRectangle(pen, rect.Left, rect.Top, rect.Width, rect.Height); } else { if ((Lines & BorderLines.Left) != 0) { LeftLine.Draw(e, rect.Left, rect.Top, rect.Left, rect.Bottom, true, (Lines & BorderLines.Top) != 0, (Lines & BorderLines.Bottom) != 0); } if ((Lines & BorderLines.Right) != 0) { RightLine.Draw(e, rect.Right, rect.Top, rect.Right, rect.Bottom, false, (Lines & BorderLines.Top) != 0, (Lines & BorderLines.Bottom) != 0); } if ((Lines & BorderLines.Top) != 0) { TopLine.Draw(e, rect.Left, rect.Top, rect.Right, rect.Top, true, (Lines & BorderLines.Left) != 0, (Lines & BorderLines.Right) != 0); } if ((Lines & BorderLines.Bottom) != 0) { BottomLine.Draw(e, rect.Left, rect.Bottom, rect.Right, rect.Bottom, false, (Lines & BorderLines.Left) != 0, (Lines & BorderLines.Right) != 0); } } } }
/// <inheritdoc/> public override bool Equals(object obj) { Border b = obj as Border; return(b != null && Lines == b.Lines && LeftLine.Equals(b.LeftLine) && TopLine.Equals(b.TopLine) && RightLine.Equals(b.RightLine) && BottomLine.Equals(b.BottomLine) && Shadow == b.Shadow && ShadowColor == b.ShadowColor && ShadowWidth == b.ShadowWidth); }
new public string ToString() { return(String.Format("\nLeftPath: {0}\nRightPath: {1}\nLeftLine: {2}\nRightLine: {3}\nRefs: {4}", (LeftPath?.ToString() ?? "null"), (RightPath?.ToString() ?? "null"), (LeftLine?.ToString() ?? "null"), (RightLine?.ToString() ?? "null"), Refs.ToString())); }
/// <summary> /// Serializes the border. /// </summary> /// <param name="writer">Writer object.</param> /// <param name="prefix">Border property name.</param> /// <param name="c">Another Border to compare with.</param> /// <remarks> /// This method is for internal use only. /// </remarks> public void Serialize(FRWriter writer, string prefix, Border c) { if (Shadow != c.Shadow) { writer.WriteBool(prefix + ".Shadow", Shadow); } if (ShadowWidth != c.ShadowWidth) { writer.WriteFloat(prefix + ".ShadowWidth", ShadowWidth); } if (ShadowColor != c.ShadowColor) { writer.WriteValue(prefix + ".ShadowColor", ShadowColor); } if (!SimpleBorder) { if (Lines != c.Lines) { writer.WriteValue(prefix + ".Lines", Lines); } if (Lines != BorderLines.None || Color != Color.Black) { if (LeftLine.Equals(RightLine) && LeftLine.Equals(TopLine) && LeftLine.Equals(BottomLine) && c.LeftLine.Equals(c.RightLine) && c.LeftLine.Equals(c.TopLine) && c.LeftLine.Equals(c.BottomLine)) { LeftLine.Serialize(writer, prefix, c.LeftLine); } else { LeftLine.Serialize(writer, prefix + ".LeftLine", c.LeftLine); TopLine.Serialize(writer, prefix + ".TopLine", c.TopLine); RightLine.Serialize(writer, prefix + ".RightLine", c.RightLine); BottomLine.Serialize(writer, prefix + ".BottomLine", c.BottomLine); } } } else { LeftLine.Serialize(writer, prefix, c.LeftLine); } }
private int HitTestFrame(Point point) { int result = 0; if (TopLeftGrip.Contains(point)) { result = WM.HTTOPLEFT; } else if (TopRightGrip.Contains(point)) { result = WM.HTTOPRIGHT; } else if (BottomLeftGrip.Contains(point)) { result = WM.HTBOTTOMLEFT; } else if (BottomRightGrip.Contains(point)) { result = WM.HTBOTTOMRIGHT; } else if (TopLine.Contains(point) || TopGrip.Contains(point)) { result = WM.HTTOP; } else if (LeftLine.Contains(point) || LeftGrip.Contains(point)) { result = WM.HTLEFT; } else if (RightLine.Contains(point) || RightGrip.Contains(point)) { result = WM.HTRIGHT; } else if (BottomLine.Contains(point) || (BottomGrip.Contains(point))) { result = WM.HTBOTTOM; } return(result); }
/// <inheritdoc/> public override int GetHashCode() { return(Lines.GetHashCode() ^ (Shadow.GetHashCode() + 16) ^ ShadowColor.GetHashCode() ^ (ShadowWidth.GetHashCode() + 32) ^ (LeftLine.GetHashCode() << 1) ^ (TopLine.GetHashCode() << 2) ^ (RightLine.GetHashCode() << 3) ^ (BottomLine.GetHashCode() << 4)); }
private bool ShouldSerializeRightLine() { return(RightLine.ShouldSerialize()); }
public void SetRights(string strUserName, string strRights) { RightLine line = null; for(int i=0;i<RightLines.Count;i++) { line = (RightLine)RightLines[i]; if (line.UserName == strUserName) goto FOUND; } line = new RightLine(); line.UserName = strUserName; this.RightLines.Add(line); FOUND: line.Rights = strRights; line.Changed = true; }
// 初始化全部对象节点的权限信息 // 本函数应当在InitialUserRecordCache()后调用, 因为要用到用户记录信息 int InitialObjRights(TreeNode parent, out string strError) { strError = ""; Debug.Assert(parent != null, ""); int i; int nRet; ObjRight objright = new ObjRight(); string strDatabaseObject = TreeViewUtil.GetPath(parent, '/'); for(i=0;i<this.m_aUserName.Count;i++) { string strUserName = (string)this.m_aUserName[i]; Debug.Assert(strUserName != "", "用户名不能为空"); string strRights = ""; nRet = GetObjectRights( this.ServerUrl, strUserName, strDatabaseObject, out strRights, out strError); if (nRet == -1) return -1; RightLine line = new RightLine(); line.UserName = strUserName; line.Rights = strRights; objright.RightLines.Add(line); } parent.Tag = objright; // 递归 for(i=0;i<parent.Nodes.Count;i++) { TreeNode child = parent.Nodes[i]; nRet = InitialObjRights(child, out strError); if (nRet == -1) return -1; } return 0; }
//Ball colitions private void OnTriggerEnter2D(Collider2D otherCollider) { // Sidelines mySideline = otherCollider.gameObject.GetComponent<Sidelines>();//get the sidelines LeftLine myLeftLine = otherCollider.gameObject.GetComponent <LeftLine>(); //get the sidelines RightLine myRightLine = otherCollider.gameObject.GetComponent <RightLine>(); //get the sidelines TopLine myTopLine = otherCollider.gameObject.GetComponent <TopLine>(); //get the Topline BottomLine myBottomline = otherCollider.gameObject.GetComponent <BottomLine>(); //get the Bottomline PlayerScript myPlayer = otherCollider.gameObject.GetComponent <PlayerScript>(); //get the Player EnemyScript myEnemy = otherCollider.gameObject.GetComponent <EnemyScript>(); //get the STD //if the collliding object is any sideline if (myRightLine != null) { MyAudioManager.BallBounce(); if (STDBallVelocity.x > 0) { STDBallVelocity.x *= -1; } STDBallVelocity = new Vector2(STDBallVelocity.x, STDBallVelocity.y); STDBallRB.velocity = STDBallVelocity; //STDBallSpeedX *= -1; } if (myLeftLine != null) { MyAudioManager.BallBounce(); if (STDBallVelocity.x < 0) { STDBallVelocity.x *= -1; } STDBallVelocity = new Vector2(STDBallVelocity.x, STDBallVelocity.y); STDBallRB.velocity = STDBallVelocity; //STDBallSpeedX *= -1; } //if the collliding object is topline else if (myTopLine != null) { MyAudioManager.BallBounce(); if (STDBallVelocity.y > 0) { STDBallVelocity.y *= -1; } STDBallVelocity = new Vector2(STDBallVelocity.x, STDBallVelocity.y); STDBallRB.velocity = STDBallVelocity; StdPongPlayScript.MyEnemyHealth -= .10f; //reduce the enemy health StdPongPlayScript.intCurrentPlayerScore += 10; //increase player points } //if the collliding object is bottomline else if (myBottomline != null) { MyAudioManager.BallBounce(); if (STDBallVelocity.y < 0) { STDBallVelocity.y *= -1; } STDBallVelocity = new Vector2(STDBallVelocity.x, STDBallVelocity.y); STDBallRB.velocity = STDBallVelocity; StdPongPlayScript.MyPlayerHealth -= .05f; //reduce the player health StdPongPlayScript.intCurrentPlayerScore -= 10; //reduce player points } else if (myPlayer != null) { MyAudioManager.BallBounce(); int RandomDirection = Random.Range(1, 3); int RandomSlantX = Random.Range(5, 8); int RandomSlantY = Random.Range(6, 10); if (RandomDirection == 1) { STDBallVelocity = new Vector2(RandomSlantX * -1f, RandomSlantY * 1f); } else { STDBallVelocity = new Vector2(RandomSlantX * 1f, RandomSlantY * 1f); } STDBallRB.velocity = STDBallVelocity; } else if (myEnemy != null) { MyAudioManager.BallBounce(); int RandomDirection = Random.Range(1, 3); int RandomSlantX = Random.Range(5, 8); int RandomSlantY = Random.Range(6, 10); if (RandomDirection == 1) { STDBallVelocity = new Vector2(RandomSlantX * -1f, RandomSlantY * -1f); } else { STDBallVelocity = new Vector2(RandomSlantX * 1f, RandomSlantY * -1f); } STDBallRB.velocity = STDBallVelocity; } }
//Bullet colitions private void OnTriggerEnter2D(Collider2D otherCollider) { LeftLine myLeftLine = otherCollider.gameObject.GetComponent <LeftLine>(); //get the sidelines RightLine myRightLine = otherCollider.gameObject.GetComponent <RightLine>(); //get the sidelines BottomLine myBottomline = otherCollider.gameObject.GetComponent <BottomLine>(); //get the Bottomline PlayerScript myPlayer = otherCollider.gameObject.GetComponent <PlayerScript>(); //get the Player EnemyScript myEnemy = otherCollider.gameObject.GetComponent <EnemyScript>(); //get the STD //if the collliding object is any sideline //if the collliding object is any sideline if (myRightLine != null) { MyAudioManager.BallBounce(); if (MovingStuffVelocity.x > 0) { MovingStuffVelocity.x *= -1; } MovingStuffVelocity = new Vector2(MovingStuffVelocity.x, MovingStuffVelocity.y); MovingStuffRB.velocity = MovingStuffVelocity; //STDBallSpeedX *= -1; } //if the collliding object is bottomline if (myLeftLine != null) { MyAudioManager.BallBounce(); if (MovingStuffVelocity.x < 0) { MovingStuffVelocity.x *= -1; } MovingStuffVelocity = new Vector2(MovingStuffVelocity.x, MovingStuffVelocity.y); MovingStuffRB.velocity = MovingStuffVelocity; //STDBallSpeedX *= -1; } //if the collliding object is bottomline else if (myBottomline != null) { transform.position = PointOutSideScreen; //bullet disappears MovePowerUp = false; //StopBulletMovement myBlinkerTextObject.transform.position = PointOutSideScreen; //transform condom blinking text MyBlinkerCounter = 0; } else if (myPlayer != null) { MovePowerUp = false; //StopBulletMovement transform.position = PointOutSideScreen; //bullet disappears //do stuff StdPongPlayScript.MyPlayerHealth += 0.05f; //increace player immune by 5% StdPongPlayScript.intCurrentPlayerScore += 3; //reduce player points myBlinkerTextObject.transform.position = PointOutSideScreen; //transform condom blinking text MyBlinkerCounter = 0; PlayerPrefs.SetInt("PowerupCount", PlayerPrefs.GetInt("PowerupCount") + 1); //increase the overall count of powerups } }
//Bullet colitions private void OnTriggerEnter2D(Collider2D otherCollider) { LeftLine myLeftLine = otherCollider.gameObject.GetComponent <LeftLine>(); //get the sidelines RightLine myRightLine = otherCollider.gameObject.GetComponent <RightLine>(); //get the sidelines BottomLine myBottomline = otherCollider.gameObject.GetComponent <BottomLine>(); //get the Bottomline PlayerScript myPlayer = otherCollider.gameObject.GetComponent <PlayerScript>(); //get the Player EnemyScript myEnemy = otherCollider.gameObject.GetComponent <EnemyScript>(); //get the STD //if the collliding object is any sideline //if the collliding object is any sideline if (myRightLine != null) { MyAudioManager.BallBounce(); if (MovingStuffVelocity.x > 0) { MovingStuffVelocity.x *= -1; } MovingStuffVelocity = new Vector2(MovingStuffVelocity.x, MovingStuffVelocity.y); MovingStuffRB.velocity = MovingStuffVelocity; //STDBallSpeedX *= -1; } //if the collliding object is bottomline if (myLeftLine != null) { MyAudioManager.BallBounce(); if (MovingStuffVelocity.x < 0) { MovingStuffVelocity.x *= -1; } MovingStuffVelocity = new Vector2(MovingStuffVelocity.x, MovingStuffVelocity.y); MovingStuffRB.velocity = MovingStuffVelocity; //STDBallSpeedX *= -1; } //if the collliding object is bottomline else if (myBottomline != null) { transform.position = PointOutSideScreen; //bullet disappears MovePowerUp = false; //StopBulletMovement myBlinkerTextObject.transform.position = PointOutSideScreen; //transform condom blinking text MyBlinkerCounter = 0; } else if (myPlayer != null) { MovePowerUp = false; //StopBulletMovement transform.position = PointOutSideScreen; //bullet disappears myPlayer.transform.localScale = new Vector2(PlayerScript.PlayerObjectSize.x * 2f, PlayerScript.PlayerObjectSize.y * 2f); //increase player size by 100% PlayerScript.SharpCondomsPlayerSizeCounter = 1; //initiate the playersize counter myBlinkerTextObject.transform.position = PointOutSideScreen; //transform condom blinking text MyBlinkerCounter = 0; //do stuff PlayerPrefs.SetInt("PowerupCount", PlayerPrefs.GetInt("PowerupCount") + 1); //increase the overall count of powerups } }