示例#1
0
        public void TestPoint()
        {
            Point pointObj = new Point();

            pointObj.AddPoint();
            pointObj.AddPoint();

            Assert.AreEqual(2, pointObj.GetPoints());
        }
示例#2
0
文件: HP.cs 项目: fmyuk/ZombieGame
    public void Die()
    {
        dead = true;

        if (replaceWhenDead)
        {
            Instantiate(deadReplacement, transform.position, transform.rotation);
        }
        if (makeExplosion)
        {
            Instantiate(explosion, transform.position, transform.rotation);
        }

        if (isPlayer && deathCam != null)
        {
            deathCam.SetActive(true);
        }

        animator.SetBool("Death", true);

        Destroy(gameObject);

        GameObject pointObj = GameObject.Find("point");
        Point      point    = pointObj.GetComponent <Point>();

        point.AddPoint(1);

        zombieGen.DecreaseZombieNum();
    }
示例#3
0
    //void StopChase()
    //{
    //    if(isHate)
    //    {
    //        if((transform.position-target.transform.position).magnitude>LoveRange)
    //        {
    //            isHate = false;
    //            Move(new Vector2(0, 0));
    //        }
    //    }
    //}

    protected void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.tag == "Player")
        {
            Player player = collision.gameObject.GetComponent <Player>();
            if (player.isPowerUP)
            {
                SoundMgr.Instance().PlaySoundEffect(3);
                // 揍飞
                isfly = true;
                GetComponent <CircleCollider2D>().enabled = false;
                Vector2 dir = player.rg.velocity;
                Move(dir * fly_speed);

                // 特效
                GameObject a = Instantiate(effect, transform.position, Quaternion.identity);
                Destroy(a, 0.4f);

                LevelPanel.levelPanel.BottomFrame();
                LevelPanel.levelPanel.ShakeObj(transform);



                //得分
                Point.AddPoint(100 * player.kill_number);
                player.kill_number++;
            }
            else
            {
                player.Damage(attack);
            }
        }
    }
示例#4
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.tag == "Player")
        {
            Player player = collision.gameObject.GetComponent <Player>();
            if (player.isPowerUP)
            {
                // 揍飞
                isfly = true;
                GetComponent <CircleCollider2D>().enabled = false;
                Vector2 dir = player.rg.velocity;
                Move(dir * fly_speed);
                //得分
                Point.AddPoint(100 * player.kill_number);
                player.kill_number++;
                //顿帧

                LevelPanel.levelPanel.BottomFrame();
                LevelPanel.levelPanel.ShakeObj(transform);
            }
            else
            {
                player.Damage(attack);
            }
        }
    }
示例#5
0
    public void AddPoint(Point p)
    {
        if (SplinePoints.Contains(p))
        {
            return;
        }
//		p.transform.parent=transform;

        //		p.transform.position=pos;
        //		point.tension=tension;
        //		point.bias=bias;
        //		point.continuity=continuity;

        p.AddSpline(this);

        int newIndex = 0;


        //ADDING POINTS OFF THE BACK OF THE START POINT
        if (SplinePoints.Count > 1 && Services.Player.GetComponent <PlayerBehaviour>().curPoint == StartPoint())
        {
            SplinePoints.Insert(0, p);
            p.AddPoint(MiddlePoint());
            MiddlePoint().AddPoint(p);
            if (closed)
            {
                p.AddPoint(SplinePoints [SplinePoints.Count - 1]);
                SplinePoints [SplinePoints.Count - 1].AddPoint(p);
            }
        }
        else
        {
            newIndex = SplinePoints.Count;
            SplinePoints.Insert(newIndex, p);

            if (newIndex == 1)
            {
                StartPoint().AddPoint(p);
                p.AddPoint(StartPoint());
            }
            else if (newIndex == 2)
            {
                MiddlePoint().AddPoint(p);
                p.AddPoint(MiddlePoint());
            }
            else if (newIndex == SplinePoints.Count - 1 && SplinePoints.Count > 2)
            {
                p.AddPoint(SplinePoints [newIndex - 1]);
                SplinePoints [newIndex - 1].AddPoint(p);
            }
            else if (newIndex > 0 && newIndex < SplinePoints.Count - 1)
            {
                p.AddPoint(SplinePoints [newIndex + 1]);
                p.AddPoint(SplinePoints [newIndex - 1]);
                SplinePoints [newIndex - 1].AddPoint(p);
                SplinePoints [newIndex + 1].AddPoint(p);
            }
        }
    }
示例#6
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            Console.WriteLine();

            Question questionObj = new Question();
            Answer   answerObj   = new Answer();
            Point    pointObj    = new Point();

            while (true)
            {
                var currentQuestion = questionObj.GetQuestion();
                if (currentQuestion == null)
                {
                    break;
                }

                Console.WriteLine();
                Console.WriteLine($"Word to guess : {currentQuestion.ShuffleWord}");
                Console.Write("Answer : ");
                var userInput = Console.ReadLine();

                var flag = answerObj.CheckAnswer(userInput, currentQuestion.OriginWord);
                if (flag)
                {
                    pointObj.AddPoint();
                    Console.WriteLine($"Good Job ! You get a point for correct answer.");
                    continue;
                }

                Console.WriteLine(answerObj.GetReason(userInput, currentQuestion.OriginWord));
                Console.WriteLine($"Correct Letters : {answerObj.GetCorectLetters(userInput, currentQuestion.OriginWord)}");
            }

            Console.WriteLine();
            Console.WriteLine($"Game over. Yout Get : {pointObj.GetPoints()} Points.");
            Console.WriteLine($"Hit enter to exit..");
            Console.ReadLine();
        }
    private void TouchScreen()
    {
        if (Input.touchCount > 0)
        {
            foreach (Touch t in Input.touches)
            {
                PointerEventData eventData = GetPED(t.fingerId);
                if (t.phase == TouchPhase.Began &&
                    eventData.pointerEnter == gameObject)
                {
                    RaycastHit2D hit = DropRay(t.position);
                    if (hit.collider == null)
                    {
                        Point.AddPoint(
                            PositionToWorldFromCamera(
                                Camera.main, t.position)
                            , prefPoint);
                    }
                }
            }
        }
        else if (Input.GetMouseButtonDown(0))
        {
            PointerEventData eventData = GetPED(-1);
            if (eventData.pointerEnter != this.gameObject)
            {
                return;
            }

            RaycastHit2D hit = DropRay(Input.mousePosition);
            if (hit.collider == null)
            {
                Point.AddPoint(
                    PositionToWorldFromCamera(
                        Camera.main, Input.mousePosition)
                    , prefPoint);
            }
        }
    }
示例#8
0
    public void PointSwitch()
    {
        Spline nextSpline    = null;
        Point  nextPoint     = null;
        bool   newSpline     = false;
        bool   newPoint      = false;
        float  angleToSpline = Mathf.Infinity;

        if (curPoint.HasSplines())
        {
            bool forward = true;

            Spline closestSpline = null;
            Point  pointDest     = null;

            foreach (Spline s in curPoint.GetSplines())
            {
                foreach (Point p in curPoint.GetNeighbours())
                {
                    if (!p._connectedSplines.Contains(s))
                    {
                        //do nothing if the point is in another spline
                    }
                    else
                    {
                        float curAngle;

                        int indexDifference = s.SplinePoints.IndexOf(p) - s.SplinePoints.IndexOf(curPoint);

                        if (indexDifference == -1 || indexDifference > 1)
                        {
                            curAngle = s.CompareAngleAtPoint(cursorDir, p, true);
                        }
                        else
                        {
                            curAngle = s.CompareAngleAtPoint(cursorDir, curPoint);
                        }

                        if (curAngle < angleToSpline)
                        {
                            angleToSpline = curAngle;
                            closestSpline = s;
                            pointDest     = p;
                        }
                    }
                }
            }

            int indexdiff = closestSpline.SplinePoints.IndexOf(pointDest) - closestSpline.SplinePoints.IndexOf(curPoint);

            if (indexdiff == -1 || indexdiff > 1)
            {
                closestSpline.Selected = pointDest;
                forward = false;
                Services.Player.GetComponent <PlayerBehaviour> ().SetProgress(1f);
            }
            else
            {
                Services.Player.GetComponent <PlayerBehaviour> ().SetProgress(0f);
                forward = true;
                closestSpline.Selected = curPoint;
            }

            if (angleToSpline <= StopAngleDiff)
            {
                nextSpline = closestSpline;
            }
        }

        if (Input.GetButton("x") && nextSpline == null && angleToSpline > LineAngleDiff)
        {
            Ray        ray = Camera.main.ScreenPointToRay(Camera.main.WorldToScreenPoint(cursor.transform.position));
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit))
            {
                if (hit.collider.tag == "Point")
                {
                    Point hitPoint = hit.collider.GetComponent <Point> ();

                    if (hitPoint == curPoint)
                    {
                        //you clicked on the node you are currently on
                    }
                    else
                    {
                        newPoint  = true;
                        nextPoint = hitPoint;
                    }
                }
            }
            else if (inventory.Count > 0)
            {
                //DOUBLE POINT ERROR IS ONLY HAPPENING IN THE MIDDLE OF LINES?

                newPoint  = true;
                nextPoint = CreatePoint(cursor.transform.position);
            }

            if (newPoint)
            {
                if (curSpline != null && (curPoint == curSpline.StartPoint() || curPoint == curSpline.EndPoint()))
                {
                    //EDGE CASE
                    //Creating endpoint when you're on startpoint
                    //make it so that the start/midpoint get shifted down one index, insert at startpoint

                    newSpline = false;

                    if (nextPoint == curSpline.StartPoint() || nextPoint == curSpline.EndPoint() && !curSpline.closed)
                    {
                        curSpline.closed    = true;
                        curSpline.LoopIndex = curSpline.SplinePoints.IndexOf(nextPoint);

                        curPoint.AddPoint(nextPoint);
                        nextPoint.AddPoint(curPoint);

                        if (curSpline.GetPointIndex(nextPoint) - curSpline.GetPointIndex(curPoint) > 1)
                        {
                            curSpline.Selected = nextPoint;
                        }
                    }
                    else
                    {
                        curSpline.AddPoint(nextPoint);
                    }

                    nextSpline     = curSpline;
                    curSpline.name = nextSpline.SplinePoints [0].name + "—" + curSpline.EndPoint().name;
                }
                else
                {
                    newSpline = true;

                    //YOU CANT JUST ADD THE NEW POINT INTO THE OLD SPLINE IF YOU'RE DOING SO IN THE MIDDLE OF THE SPLINE
                    //IT WILL CREATE PROBLEMS. IT WONT KNOW THE PROPER NEIGHBOURS
                    //MAYBE INSERT IT AT A POSITION
                    //If at the end or start of the current line, insert the new point at the ends
                    //if not, don't insert it

//					if (curSpline != null && !curSpline.SplinePoints.Contains (nextPoint)) {
//						curSpline.AddPoint (nextPoint);
//					}


                    nextSpline = CreateSpline(nextPoint);
                }
            }
        }

        //BREAK OUT OF FUNCTION BEFORE THE NEXT SPLINE IS SET TO THE CURRENT SPLINE

        if (!newPoint && nextSpline == null)
        {
            flow = Mathf.Lerp(flow, 0, decay * Time.deltaTime);

//			transform.position = curPoint.transform.position;

            return;
        }
        else
        {
            //SET NEXT SPLINE TO CURRENT SPLINE
            curSpline = nextSpline;
            curSpline.OnSplineExit();

            if (newPoint)
            {
                if (curPoint == curSpline.Selected)
                {
                    if (!goingForward)
                    {
//					flow = -flow;
                    }
                    goingForward = true;
                    progress     = 0;
                }
                else
                {
                    if (goingForward)
                    {
//					flow = -flow;
                    }
                    goingForward = false;
                    progress     = 1;
                }
            }

            traversing = true;
        }
    }
示例#9
0
        /// <summary>
        /// 编辑会员积分
        /// </summary>
        public void UserPoint_Edit()
        {
            int        id = RequestTool.RequestInt("id", 0);
            SearchUser su = new SearchUser(CurrentAdmin, CurrentLanguage.Code);

            if (id > 0)
            {
                if (!EX_Admin.Power("user_point_edit", "编辑会员积分"))
                {
                    AjaxNoPower();
                    return;
                }
                Lebi_User_Point model = B_Lebi_User_Point.GetModel(id);
                Lebi_User       user  = B_Lebi_User.GetModel(model.User_id);
                Log.Add("编辑会员积分", "User_Point", id.ToString(), CurrentAdmin, user.UserName);
                if (user == null)
                {
                    Response.Write("{\"msg\":\"" + Tag("会员账号不存在") + "\"}");
                    return;
                }
                model.Point = RequestTool.RequestDecimal("Point", 0);
                model.Type_id_PointStatus = RequestTool.RequestInt("Type_id_PointStatus", 0);
                model.Admin_UserName      = CurrentAdmin.UserName;
                model.Admin_id            = CurrentAdmin.id;
                model.Remark      = RequestTool.RequestString("Remark");
                model.Time_Update = DateTime.Now;
                B_Lebi_User_Point.Update(model);
                Point.UpdateUserPoint(user);
            }
            else
            {
                if (!EX_Admin.Power("user_point_add", "添加会员积分"))
                {
                    AjaxNoPower();
                    return;
                }
                string Mode          = RequestTool.RequestString("mode");
                string User_Name_To  = RequestTool.RequestString("User_Name_To");
                string UserLevel_ids = RequestTool.RequestString("UserLevel_ids");
                string User_ids      = RequestTool.RequestString("User_ids");
                string UserName_ids  = RequestTool.RequestString("UserName_ids");

                if (Mode == "user")
                {
                    Lebi_User user = B_Lebi_User.GetModel("UserName = lbsql{'" + User_Name_To + "'}");
                    if (user == null)
                    {
                        Response.Write("{\"msg\":\"" + Tag("会员账号不存在") + "\"}");
                        return;
                    }
                    Log.Add("添加会员积分", "User_Point", id.ToString(), CurrentAdmin, User_Name_To + " ->" + RequestTool.RequestDecimal("Point", 0));
                    Point.AddPoint(user, RequestTool.RequestDecimal("Point", 0), RequestTool.RequestInt("Type_id_PointStatus", 0), CurrentAdmin, RequestTool.RequestSafeString("Remark"));
                }
                else
                {
                    string where = "";
                    int i = 0;
                    if (User_ids == "")
                    {
                        Response.Write("{\"msg\":\"" + Tag("没有选择任何数据") + "\"}");
                        return;

                        where = "1=1 " + su.SQL;
                        Log.Add("添加会员积分", "User_Point", "", CurrentAdmin, su.Description + " ->" + RequestTool.RequestDecimal("Point", 0));
                    }
                    else
                    {
                        where = "id in (" + User_ids + ")";
                        Log.Add("添加会员积分", "User_Point", "", CurrentAdmin, UserName_ids + " ->" + RequestTool.RequestDecimal("Point", 0));
                    }
                    List <Lebi_User> modellist = B_Lebi_User.GetList(where, "");
                    foreach (Lebi_User user in modellist)
                    {
                        Point.AddPoint(user, RequestTool.RequestDecimal("Point", 0), RequestTool.RequestInt("Type_id_PointStatus", 0), CurrentAdmin, RequestTool.RequestSafeString("Remark"));
                    }
                }
            }
            string result = "{\"msg\":\"OK\"}";

            Response.Write(result);
        }