Summary description for ClickData
Exemple #1
0
        private static DialData FillDialSpecialAbilities(DialData dial, Guid id)
        {
            SqlConnection connection = MageKnightDataDB.GetConnection();
            string        selectStatement
                = "SELECT Speed, Attack, Defense, Damage, [Index] "
                  + "FROM ClickAbilities "
                  + "WHERE Id = @Id";
            SqlCommand selectCommand = new SqlCommand(selectStatement, connection);

            selectCommand.Parameters.AddWithValue("@Id", id);
            try
            {
                connection.Open();
                SqlDataReader reader = selectCommand.ExecuteReader();
                while (reader.Read())
                {
                    int       index = Int32.Parse(reader["Index"].ToString());
                    ClickData click = dial.Clicks.First(x => x.Index == index);
                    click.Speed.Ability   = reader["Speed"].ToString();
                    click.Attack.Ability  = reader["Attack"].ToString();
                    click.Defense.Ability = reader["Defense"].ToString();
                    click.Damage.Ability  = reader["Damage"].ToString();
                }

                return(dial);
            }
            catch (Exception ex)
            {
                MessageBox.Show($"something is wrong GetMageKnight:{ex.ToString()}");
            }

            return(null);
        }
Exemple #2
0
    public void OnPointerDown(PointerEventData eventData)
    {
        if (!_touchIds.ContainsKey(eventData.pointerId))
        {
            Vector3   pos  = eventData.position;
            ClickData data = new ClickData();
            data.Position  = pos;
            data.ClickTime = 0;
            _touchIds.Add(eventData.pointerId, data);
        }

        if (_touchIds.Count >= 2)
        {
            //算出两个触摸点的距离
            int     n    = 0;
            Vector3 pos1 = Vector3.zero;
            Vector3 pos2 = Vector3.zero;
            foreach (KeyValuePair <int, ClickData> id in _touchIds)
            {
                if (n == 0)
                {
                    pos1 = id.Value.Position;
                }
                if (n == 1)
                {
                    pos2 = id.Value.Position;
                    break;
                }
                n++;
            }
            _distanceScale = Vector3.Distance(pos1, pos2);
        }
    }
Exemple #3
0
 public void AddClickData(ClickData clickData)
 {
     if (isstarted)
     {
         L2S.Add(clickData);
     }
 }
 private void SendBetaClickData()
 {
     if (thisType.valence == 6 && (!thisType.elementName.StartsWith("Sc")))
     {
         List <GameObject> activeOxygens = new List <GameObject>();
         foreach (var t in from el in Info.allElements
                  where el.valence == 0
                  select el)
         {
             foreach (var e in t.allInstases)
             {
                 if (e.activeSelf)
                 {
                     activeOxygens.Add(e);
                 }
             }
         }
         GameObject[] oxygens   = activeOxygens.ToArray();
         float[]      distances = new float[oxygens.Length];
         for (int i = 0; i < oxygens.Length; i++)
         {
             distances[i] = Vector3.Distance(transform.localPosition, oxygens[i].transform.localPosition);
         }
         Array.Sort(distances, oxygens);
         GameObject a = oxygens[0];
         GameObject b = null;
         for (int i = 1; i < 6; i++)
         {
             if (oxygens[i].transform.position.y == a.transform.position.y)
             {
                 continue;
             }
             if (b == null)
             {
                 b = oxygens[i];
                 continue;
             }
             if ((a.transform.position - b.transform.position).magnitude > (a.transform.position - oxygens[i].transform.position).magnitude)
             {
                 b = oxygens[i];
             }
         }
         CoordScript scr  = GetComponent <CoordScript>();
         float       z    = scr.z;
         ClickData   beta = new ClickData(Info.a, Info.b, Info.c, scr.x, scr.y, z);
         beta.name = this.name;
         beta.beta = true;
         scr       = a.GetComponent <CoordScript>();
         beta.ang1 = new ClickData(Info.a, Info.b, Info.c, scr.x, scr.y, z);
         scr       = b.GetComponent <CoordScript>();
         beta.ang3 = new ClickData(Info.a, Info.b, Info.c, scr.x, scr.y, z);
         Info.sendClickDatatoWin(beta);
     }
 }
        ClickBubble IClickableService.OnClicked(int instanceID)
        {
            var position = this.Owner.MainCamera.ScreenToWorldPoint(Input.mousePosition);
            var data     = new ClickData();

            data.Position             = position;
            data.Screen               = Input.mousePosition;
            data.GameObjectInstanceID = instanceID;

            return(this.Owner.OnClicked(data));
        }
Exemple #6
0
    void Update()
    {
        bool n = Input.GetMouseButton(0);

        if (!n)
        {
            f = n;
            return;
        }
        if (f)
        {
            return;
        }
        f = n;
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        RaycastHit[] hits = Physics.RaycastAll(ray);
        bool         flag = false;

        foreach (var h in hits)
        {
            if (h.transform.gameObject.name != "triangle")
            {
                flag = true;
            }
        }

        if (flag) //&& hit.collider.gameObject.name == "Yify")
        {
            float      distance = float.MaxValue;
            GameObject target   = null;
            foreach (var h in hits)
            {
                if (h.transform.gameObject.name != "triangle" && h.distance < distance)
                {
                    distance = h.distance;
                    target   = h.transform.gameObject;
                }
            }
            ClickData c = new ClickData();
            c.name = target.name;
            CoordScript scr = target.GetComponent <CoordScript>();
            c.a    = Info.a;
            c.b    = Info.b;
            c.c    = Info.c;
            c.x    = scr.x;
            c.y    = scr.y;
            c.z    = scr.z;
            c.beta = false;
            Info.sendClickDatatoWin(c);
        }
    }
    public override void OnPointerDown(PointerEventData eventData)
    {
        if (MotionType != TextureInstanced.Instance.Type)
        {
            return;
        }
        base.OnPointerDown(eventData);
        //  Debug.Log("this is OnPointerDown  eventData.clickTime " + eventData.clickTime);

        if (!_touchIds.ContainsKey(eventData.pointerId))
        {
            Vector3   pos  = eventData.position;
            ClickData data = new ClickData();
            data.Position  = pos;
            data.ClickTime = 0;
            _touchIds.Add(eventData.pointerId, data);
        }
    }
Exemple #8
0
    public static void sendClickDatatoWin(ClickData c)
    {
        if (File.Exists("data.xml"))
        {
            Thread.Sleep(500);
        }
        Int32         port   = 2201;
        TcpClient     client = new TcpClient("127.0.0.1", port);
        NetworkStream stream = client.GetStream();

        using (FileStream fstream = new FileStream("data.xml", FileMode.Create))
        {
            (new XmlSerializer(typeof(ClickData))).Serialize(fstream, c);
            fstream.Close();
        }
        stream.WriteByte(0);
        stream.Close();
        client.Close();
    }
Exemple #9
0
        private static DialData GetDialStats(MageData data)
        {
            SqlConnection connection = MageKnightDataDB.GetConnection();
            string        selectStatement
                = "SELECT Speed, Attack, Defense, Damage, [Index] "
                  + "FROM ClickValues "
                  + "WHERE Id = @Id";
            SqlCommand selectCommand = new SqlCommand(selectStatement, connection);

            selectCommand.Parameters.AddWithValue("@Id", data.Id);
            DialData dial = new DialData(data);

            try
            {
                connection.Open();
                SqlDataReader reader = selectCommand.ExecuteReader();
                while (reader.Read())
                {
                    StatData speed   = new StatData(StatType.Speed);
                    StatData attack  = new StatData(StatType.Attack);
                    StatData defense = new StatData(StatType.Defense);
                    StatData damage  = new StatData(StatType.Damage);

                    speed.Value   = Int32.Parse(reader["Speed"].ToString());
                    attack.Value  = Int32.Parse(reader["Attack"].ToString());
                    defense.Value = Int32.Parse(reader["Defense"].ToString());
                    damage.Value  = Int32.Parse(reader["Damage"].ToString());
                    int       index = Int32.Parse(reader["Index"].ToString());
                    ClickData click = new ClickData(speed, attack, defense, damage, index);
                    dial.Clicks.Add(click);
                }

                connection.Close();
                return(FillDialSpecialAbilities(dial, data.Id));
            }
            catch (Exception ex)
            {
                MessageBox.Show($"something is wrong GetMageKnight:{ex.ToString()}");
            }

            return(null);
        }
Exemple #10
0
    private void storeClick(bool timeout = false)
    {
        // Position of the mouse when the trial started
        clickData.startPos = cursorStartPos;
        // Current position of the mouse
        clickData.endPos       = CursorManager.Instance.getCursorPos();
        clickData.goalPos      = TargetManager.Instance.GoalObject.transform.localPosition;
        clickData.movementTime = movementTime;
        clickData.timeout      = timeout;

        // If there were no misclicks, set the list to null
        if (clickData.misClickPos.Count == 0)
        {
            clickData.misClickPos = null;
        }

        // The end position of this click is the start
        // position of the next click
        cursorStartPos = CursorManager.Instance.getCursorPos();

        trialData.clicks.Add(clickData);
        clickData = new ClickData();
    }
Exemple #11
0
 void Update()
 {
     if (Input.GetKeyDown(Code_G))
     {
         //Debug.Log("G Pressed");
         if (slink.KeyGSkill != null)
         {
             ClickData cd = new ClickData();
             cd.Ksetdata(slink.KeyGSkill);
             theNW.AddClickData(cd);
             //Debug.Log("G Logged");
         }
     }
     if (Input.GetKeyDown(Code_C))
     {
         if (slink.KeyCSkill != null)
         {
             ClickData cd = new ClickData();
             cd.Ksetdata(slink.KeyCSkill);
             theNW.AddClickData(cd);
         }
     }
     if (Input.GetKeyDown(Code_R))
     {
         if (slink.KeyRSkill != null)
         {
             ClickData cd = new ClickData();
             cd.Ksetdata(slink.KeyRSkill);
             theNW.AddClickData(cd);
         }
     }
     if (Input.GetKeyDown(Code_T))
     {
         if (slink.KeyTSkill != null)
         {
             ClickData cd = new ClickData();
             cd.Ksetdata(slink.KeyTSkill);
             theNW.AddClickData(cd);
         }
     }
     if (Input.GetKeyDown(Code_F))
     {
         if (slink.KeyFSkill != null)
         {
             ClickData cd = new ClickData();
             cd.Ksetdata(slink.KeyFSkill);
             theNW.AddClickData(cd);
         }
     }
     if (Input.GetKeyDown(Code_D))
     {
         if (slink.KeyDSkill != null)
         {
             ClickData cd = new ClickData();
             cd.Ksetdata(slink.KeyDSkill);
             theNW.AddClickData(cd);
         }
     }
     if (Input.GetKeyDown(Code_E))
     {
         if (slink.KeyESkill != null)
         {
             ClickData cd = new ClickData();
             cd.Ksetdata(slink.KeyESkill);
             theNW.AddClickData(cd);
         }
     }
     if (Input.GetKeyDown(Code_Y))
     {
         if (slink.KeyYSkill != null)
         {
             ClickData cd = new ClickData();
             cd.Ksetdata(slink.KeyYSkill);
             theNW.AddClickData(cd);
         }
     }
     if (Input.GetKeyDown(Code_S))
     {
         ClickData cd = new ClickData();
         cd.Ksetdata(SkillCode.FireStop);
         theNW.AddClickData(cd);
     }
     if (Input.GetMouseButtonDown(0))
     {
         Vector2   mp = Camera.main.ScreenToWorldPoint(Input.mousePosition);
         ClickData cd = new ClickData();
         if (Physics2D.OverlapPoint(mp) && Physics2D.OverlapPoint(mp).GetComponent <HPScript>() != null)
         {
             cd.Ssetdata(Physics2D.OverlapPoint(mp).gameObject.name);
         }
         else
         {
             cd.Msetdata(MButton.left, mp.x, mp.y); //Debug.Log("MButton Left Clicked X:" + mp.x);
         }
         theNW.AddClickData(cd);
     }
     if (Input.GetMouseButtonDown(1))
     {
         Vector2   mp = Camera.main.ScreenToWorldPoint(Input.mousePosition);
         ClickData cd = new ClickData();
         cd.Msetdata(MButton.right, mp.x, mp.y);
         theNW.AddClickData(cd);
     }
 }
Exemple #12
0
 public void Update(ClickData click)
 {
     _context.Clicks.Attach(click);
     _context.Entry(click).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
     _context.SaveChanges();
 }
Exemple #13
0
 public void Create(ClickData click)
 {
     _context.Clicks.Add(click);
     _context.SaveChanges();
 }
Exemple #14
0
 void Update()
 {
     if (!TotalSwitch.isOn)
     {
         return;
     }
     if (Input.GetKeyDown(KeyCode.G))
     {
         if (slink.KeyGSkill != null)
         {
             ClickData cd = new ClickData();
             cd.Ksetdata(slink.KeyGSkill);
             theNW.L2S.Add(cd);
         }
     }
     if (Input.GetKeyDown(KeyCode.C))
     {
         if (slink.KeyCSkill != null)
         {
             ClickData cd = new ClickData();
             cd.Ksetdata(slink.KeyCSkill);
             theNW.L2S.Add(cd);
         }
     }
     if (Input.GetKeyDown(KeyCode.R))
     {
         if (slink.KeyRSkill != null)
         {
             ClickData cd = new ClickData();
             cd.Ksetdata(slink.KeyRSkill);
             theNW.L2S.Add(cd);
         }
     }
     if (Input.GetKeyDown(KeyCode.T))
     {
         if (slink.KeyTSkill != null)
         {
             ClickData cd = new ClickData();
             cd.Ksetdata(slink.KeyTSkill);
             theNW.L2S.Add(cd);
         }
     }
     if (Input.GetKeyDown(KeyCode.F))
     {
         if (slink.KeyFSkill != null)
         {
             ClickData cd = new ClickData();
             cd.Ksetdata(slink.KeyFSkill);
             theNW.L2S.Add(cd);
         }
     }
     if (Input.GetKeyDown(KeyCode.D))
     {
         if (slink.KeyDSkill != null)
         {
             ClickData cd = new ClickData();
             cd.Ksetdata(slink.KeyDSkill);
             theNW.L2S.Add(cd);
         }
     }
     if (Input.GetKeyDown(KeyCode.E))
     {
         if (slink.KeyESkill != null)
         {
             ClickData cd = new ClickData();
             cd.Ksetdata(slink.KeyESkill);
             theNW.L2S.Add(cd);
         }
     }
     if (Input.GetKeyDown(KeyCode.Y))
     {
         if (slink.KeyYSkill != null)
         {
             ClickData cd = new ClickData();
             cd.Ksetdata(slink.KeyYSkill);
             theNW.L2S.Add(cd);
         }
     }
     if (Input.GetKeyDown(KeyCode.S))
     {
         ClickData cd = new ClickData();
         cd.Ksetdata(SkillCode.FireStop);
         theNW.L2S.Add(cd);
     }
     if (Input.GetMouseButtonDown(0))
     {
         Vector2   mp = Camera.main.ScreenToWorldPoint(Input.mousePosition);
         ClickData cd = new ClickData();
         if (Physics2D.OverlapPoint(mp) && Physics2D.OverlapPoint(mp).GetComponent <HPScript>() != null)
         {
             cd.Ssetdata(Physics2D.OverlapPoint(mp).gameObject.name);
         }
         else
         {
             cd.Msetdata(MButton.left, mp.x, mp.y);
         }
         theNW.L2S.Add(cd);
     }
     if (Input.GetMouseButtonDown(1))
     {
         Vector2   mp = Camera.main.ScreenToWorldPoint(Input.mousePosition);
         ClickData cd = new ClickData();
         cd.Msetdata(MButton.right, mp.x, mp.y);
         theNW.L2S.Add(cd);
     }
 }
Exemple #15
0
        public static void Main(string[] args)
        {
            var render     = new ConsoleRender();
            var score      = new Score();
            var click_data = new ClickData();

            var items = new List <Item> {
                new Item(10, 0.1m, "First Item"),
                new Item(50, 1.1m, "Second Item")
            };
            var   focus = new Focus(render);
            State state = new State(render)
            {
                ClickData = click_data,
                Score     = score,
                Items     = items,
                Focus     = focus
            };

            click_data.OnClick = (state) =>
            {
                state.Score.Value += click_data.ClickValue;
                click_data.TotalClicks++;
                render.Update();
            };
            render.Add(score);
            render.Add(state);
            render.Add(click_data);
            items.ForEach(item =>
            {
                render.Add(item);
                focus.Add(item);
            });
            render.Add(new Hints());
            new TimerBasedAction(1000, () =>
            {
                score.Value += state.TotalIncome;
                render.Update();
            }).Start();
            new Thread(
                new ThreadStart(() =>
            {
                Take_User_Input:
                var input = Console.ReadKey(true).Key;
                if (UserInputs.InputMap.TryGetValue(input, out Action <State> action))
                {
                    action.Invoke(state);
                    render.Update();
                }
                goto Take_User_Input;
            })
                ).Start();

            var _quitEvent = new ManualResetEvent(false);

            Console.CancelKeyPress += (sender, eArgs) => {
                _quitEvent.Set();
                eArgs.Cancel = true;
            };
            // kick off asynchronous stuff
            Console.BackgroundColor = ConsoleColor.DarkBlue;
            render.Update();
            _quitEvent.WaitOne();
        }