Пример #1
0
    public void SingleClick(Vector2 vect)
    {
        if (GameRunningScript.getInstance().isClickActive == false)
        {
            return;
        }
        Ray        ray = cam.ScreenPointToRay(vect);
        RaycastHit point;

        if (Physics.Raycast(ray, out point, 20000, layerMask))
        {
            if (point.collider.gameObject.GetComponent <PlayerControlScript>() != null)
            {
                PlayerControlScript player = point.collider.gameObject.GetComponent <PlayerControlScript>();
                player.setSelected(true);
            }
            else if (point.collider.gameObject.GetComponent <CheckPoints>() != null)
            {
                CheckPoints check = point.collider.gameObject.GetComponent <CheckPoints>();
                if (!check.getClickable())
                {
                    return;
                }
                if (GameRunningScript.getInstance().selectedPlayer == null)
                {
                    return;
                }
                //TODO Do a method to decide the transport method
                GameRunningScript.getInstance().myPlayer.sendMove(check, TransportType.Cycle);
                GameRunningScript.getInstance().selectedPlayer.moveMyPlayer(check, TransportType.Cycle);
                Dev.log(Tag.GameClickListener, "Hit : " + check.name);
            }
        }
    }
Пример #2
0
        public CheckPoints Check(int Check_Id, String Check_Points, String Category, String Developer, String QC_Resource, String Comment)
        {
            con.Open();
            SqlDataReader reader = null;
            string        str    = "select c.Check_Id,c.Category,c.Check_Points, i.Developer, i.QC_Resource, i.Comment from QC_Check_Points c, QC_Userdata i WHERE Category = '{0}'";

            string sql = string.Format(str, Category);

            SqlCommand cmd = new SqlCommand(sql, con);

            reader = cmd.ExecuteReader();
            CheckPoints pts = null;

            if (reader.Read())
            {
                pts = new CheckPoints()
                {
                    Check_Id     = Convert.ToInt32(reader["Check_Id"]),
                    Category     = reader["Category"].ToString(),
                    Check_Points = reader["Check_Points"].ToString(),
                    Developer    = reader["Developer"].ToString(),
                    QC_Resource  = reader["QC_Resource"].ToString(),
                    Comment      = reader["Comment"].ToString(),
                };
            }
            con.Close();
            return(pts);
        }
Пример #3
0
        public RunnerModel(string Name, float Distance, RaceModel race)
        {
            this.Name = Name;
            Race      = race ?? new RaceModel();

            int CeilLapsCount = (int)Math.Ceiling(Distance / Race.LapLength);

            if (SettingsModel.FirstLapAlwaysFull)
            {
                var LastLapLength = Distance % Race.LapLength == 0 ? Race.LapLength : Distance % Race.LapLength;
                for (float i = 1; i < CeilLapsCount; ++i)
                {
                    CheckPoints.Add(Race.LapLength);
                }
                CheckPoints.Add(LastLapLength);
            }
            else
            {
                var FirstLapLength = (Distance % Race.LapLength == 0) ? Race.LapLength : Distance % Race.LapLength;
                CheckPoints.Add(FirstLapLength);
                for (float i = 1; i < CeilLapsCount; ++i)
                {
                    CheckPoints.Add(Race.LapLength);
                }
            }
        }
Пример #4
0
    void Awake()
    {
        if (Instance != null)
        {
            return;
        }

        Instance = this;
    }
Пример #5
0
 protected virtual void Point(CheckPoint point)
 {
     if (point == null)
     {
         throw new ArgumentNullException();
     }
     CheckPoints?.Invoke(this, point);
     Flag = point.Flag;
 }
Пример #6
0
    public static void saveData(CheckPoints checkpoints)
    {
        BinaryFormatter formatter = new BinaryFormatter();
        string          path      = Application.persistentDataPath + "/savadata.txt";
        FileStream      stream    = new FileStream(path, FileMode.Create);

        SaveData savingData = new SaveData(checkpoints);

        formatter.Serialize(stream, savingData);
        stream.Close();
    }
Пример #7
0
 public bool checkExistence(List <PlayerControlScript> list, CheckPoints check)
 {
     foreach (PlayerControlScript ch in list)
     {
         if (ch.getCurrentCheck().name == check.name)
         {
             return(true);
         }
     }
     return(false);
 }
Пример #8
0
 public SaveData(CheckPoints checkPoints)
 {
     firstPlay           = CheckPoints.firstPlay;
     beatFirstBoss       = CheckPoints.passedFirstCheckpoint;
     beatSecondBoss      = CheckPoints.passedSecondCheckpoint;
     beatThirdBoss       = CheckPoints.passedThirdCheckpoint;
     beatFourthBoss      = CheckPoints.passedFourthCheckpoint;
     beatFifthBoss       = CheckPoints.passedFifthCheckPoint;
     beatSixthBoss       = CheckPoints.passedSixthCheckPoint;
     passedDecisionStage = CheckPoints.passedDecisionStage;
 }
 public void sendMove(CheckPoints check, TransportType type)
 {
     if (GameRunningScript.getInstance().myPlayerChar == Character.Police)
     {
         netView.RPC("policeSendMove", RPCMode.OthersBuffered, new object[] { GameRunningScript.getInstance().selectedPlayer.getIndex()
                                                                              , check.getIndex(), (int)type });
     }
     else
     {
         netView.RPC("thiefSendMoves", RPCMode.OthersBuffered, new object[] { (int)type });
     }
 }
Пример #10
0
    void Start()
    {
        currentHp = info.health;

        enemies     = Enemies.Instance;
        checkPoints = CheckPoints.Instance;

        targetedCheckpoint = checkPoints.checkpoints[checkPointNum];

        // find direction
        direction = targetedCheckpoint.position - transform.position;
        direction.Normalize();
    }
Пример #11
0
 public SimpleKMP()
 {
     StartPositions       = new StartPositions();
     EnemyRoutes          = new EnemyRoutes();
     ItemRoutes           = new ItemRoutes();
     CheckPoints          = new CheckPoints();
     Objects              = new Objects();
     Routes               = new Routes();
     Area                 = new Area();
     Camera               = new Camera();
     RespawnPoints        = new RespawnPoints();
     GliderRoutes         = new GliderRoutes();
     StageInformation     = new StageInformation();
     currentCullingRoutes = new List <int>();
 }
Пример #12
0
        public IEnumerable <Block> GetCheckpointBlocks()
        {
            var idsCheckpointBlocks       = CheckPoints.SelectMany(c => c.IdsBlocks);
            var sprocsCheckpointBlocks    = CheckPoints.SelectMany(c => c.SprocsBlocks);
            var functionsCheckpointBlocks = CheckPoints.SelectMany(c => c.FunctionsBlocks);
            var triggersCheckpointBlocks  = CheckPoints.SelectMany(c => c.TriggersBlocks);
            var docCheckpointBlocks       = CheckPoints
                                            .SelectMany(c => c.DocumentBatches.SelectMany(b => b.Blocks));

            return(idsCheckpointBlocks
                   .Concat(sprocsCheckpointBlocks)
                   .Concat(functionsCheckpointBlocks)
                   .Concat(triggersCheckpointBlocks)
                   .Concat(docCheckpointBlocks));
        }
    private void policeAskRAdius(int ind, int radius)
    {
        CheckPoints check     = gameClickHandler.allChecks[ind];
        Vector3     playerPos = check.transform.position;
        Vector3     myPos     = myThief.transform.position;
        float       dist2     = GameMethods.getSqrDist(playerPos, myPos);

        if (radius * radius < dist2 * dist2)
        {
            netView.RPC("thiefAskRadiusAnswer", RPCMode.OthersBuffered, new object[] { false });
        }
        else
        {
            netView.RPC("thiefAskRadiusAnswer", RPCMode.OthersBuffered, new object[] { true });
        }
    }
Пример #14
0
 private void initMyPlayer(CheckPoints ch, Character c, int ind)
 {
     isDisabled   = false;
     character    = c;
     index        = ind;
     currentCheck = ch;
     if (character != GameRunningScript.getInstance().myPlayerChar)
     {
         isDisabled = true;
     }
     Dev.log(Tag.PlayerControllerScript, "Initiatin the player at " + currentCheck.transform.position + " : " + currentCheck.getIndex());
     transform.position    = currentCheck.transform.position;
     meshRenderer.material = unselectedMat;
     isClickable           = true;
     setSelected(false);
 }
Пример #15
0
        public Tip(CheckPoints point)
        {
            InitializeComponent();

            tbCheckId.Text     = point.CheckPointId.ToString();
            lbiDrinks.Content  = point.Drinks.ToString();
            lbiBars.Content    = point.EnergyBars.ToString();
            lbiToilets.Content = point.Toilets.ToString();
            lbiInfo.Content    = point.Information.ToString();
            lbiMed.Content     = point.Medicial.ToString();

            SetContent(lbiDrinks);
            SetContent(lbiBars);
            SetContent(lbiToilets);
            SetContent(lbiInfo);
            SetContent(lbiMed);
        }
Пример #16
0
        public List <CheckPoints> LoadSavedUserDATA(string Client_Code, string Project_Code, string Ext_Code)
        {
            List <CheckPoints> SaveData = new List <CheckPoints>();
            SqlDataReader      reader   = null;
            CheckPoints        pts      = null;

            try
            {
                con.Open();

                string     str = "select cp.Check_Id,ud.Developer,ud.QC_Resource,ud.Comment,ud.Developer_1,ud.QC_Resource_1,ud.Comment_1,ud.Developer_2,ud.QC_Resource_2,ud.Comment_2 from QC_Check_Points cp left outer join QC_Userdata ud on cp.Check_Id = ud.Check_Id left outer join QC_Info inf on ud.Client_Code = inf.Client_Code and ud.Ext_Code = inf.Ext_Code and ud.Project_Code = inf.Project_Code where inf.Client_Code = '{0}' and inf.Project_Code = '{1}' and inf.Ext_Code = '{2}' order by  cp.Check_Id";
                string     sql = string.Format(str, Client_Code, Project_Code, Ext_Code);
                SqlCommand cmd = new SqlCommand(sql, con);
                reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    pts = new CheckPoints()
                    {
                        Check_Id    = Convert.ToInt32(reader["Check_Id"]),
                        Developer   = reader["Developer"].ToString(),
                        QC_Resource = reader["QC_Resource"].ToString(),
                        Comment     = reader["Comment"].ToString(),

                        Developer_1   = reader["Developer_1"].ToString(),
                        QC_Resource_1 = reader["QC_Resource_1"].ToString(),
                        Comment_1     = reader["Comment_1"].ToString(),

                        Developer_2   = reader["Developer_2"].ToString(),
                        QC_Resource_2 = reader["QC_Resource_2"].ToString(),
                        Comment_2     = reader["Comment_2"].ToString(),
                    };
                    SaveData.Add(pts);
                }
                return(SaveData);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                con.Close();
            }
        }
Пример #17
0
    void Start()
    {
        lives       = FindObjectOfType <PlayerLives>();
        PlayerLives = GetComponent <PlayerLives>();

        checkPoints = GetComponent <CheckPoints>();

        rangerController = GetComponent <rangerController>();

        pc = GetComponent <PlayerController>();

        PlayerAudio = GetComponent <AudioSource>();

        anim = GetComponent <Animator>();

        healthBar.value = maxHealth;
        currentHealth   = healthBar.value;
    }
Пример #18
0
    private IEnumerator moveToPlace(CheckPoints orig, CheckPoints next, TransportType type)
    {
        isMoving    = true;
        isClickable = false;
        Vector3 finalPos = next.transform.position;
        float   speed    = getSpeed(type);

        while (true)
        {
            //TODO Move at a given rate(tranport)
            Vector3 cur = GameMethods.getProjectionWithSpeed(finalPos, transform.position, speed, Time.deltaTime);
            transform.position = cur;
            if (cur == finalPos)
            {
                break;
            }
            yield return(new WaitForEndOfFrame());
        }
        isMoving = false;
        if (GameRunningScript.getInstance().selectedPlayer == this)
        {
            controller.showCooldownWindow();
        }
        currentTime = coolDownTime;
        while (currentTime > 0)
        {
            if (GameRunningScript.getInstance().selectedPlayer == this)
            {
                controller.setCooldownTime(currentTime);
            }
            yield return(new WaitForSeconds(1));

            currentTime--;
        }
        currentCheck = next;
        isClickable  = true;
        if (GameRunningScript.getInstance().selectedPlayer == this)
        {
            setSelected(false);
            setSelected(true);
        }
        yield break;
    }
Пример #19
0
        public SimpleKMP(byte[] data)
        {
            KMP kmp_data;

            kmp_data = new KMP(data);

            StartPositions       = new StartPositions(kmp_data.KartPoint);
            EnemyRoutes          = new EnemyRoutes(kmp_data.EnemyPoint, kmp_data.EnemyPointPath);
            ItemRoutes           = new ItemRoutes(kmp_data.ItemPoint, kmp_data.ItemPointPath);
            CheckPoints          = new CheckPoints(kmp_data.CheckPoint, kmp_data.CheckPointPath);
            Objects              = new Objects(kmp_data.GlobalObject);
            Routes               = new Routes(kmp_data.PointInfo);
            Area                 = new Area(kmp_data.Area);
            Camera               = new Camera(kmp_data.Camera);
            RespawnPoints        = new RespawnPoints(kmp_data.JugemPoint);
            GliderRoutes         = new GliderRoutes(kmp_data.GliderPoint, kmp_data.GliderPointPath);
            StageInformation     = new StageInformation(kmp_data.StageInfo);
            currentCullingRoutes = new List <int>();
        }
Пример #20
0
        public List <KeyValuePair <string, CheckPoints> > UserCheckPointsList(int Check_Id, String Check_Points, String Category, String Developer, String QC_Resource, String Comment)
        {
            // string category = "";
            List <CheckPoints> SelectedPointsList = new List <CheckPoints>();
            var categorisedCheckPoints            = new List <KeyValuePair <string, CheckPoints> >();

            con.Open();
            try
            {
                string str = "select c.Check_Id,c.Category,c.Check_Points, i.Developer, i.QC_Resource, i.Comment from QC_Check_Points c, QC_Userdata i WHERE Category = '{0}'";

                string sql = string.Format(str, Category);

                SqlCommand    cmd    = new SqlCommand(sql, con);
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    Category = reader["Category"].ToString();
                    CheckPoints pts = new CheckPoints()
                    {
                        Check_Id     = Convert.ToInt32(reader["Check_Id"]),
                        Category     = reader["Category"].ToString(),
                        Check_Points = reader["Check_Points"].ToString(),
                        Developer    = reader["Developer"].ToString(),
                        QC_Resource  = reader["QC_Resource"].ToString(),
                        Comment      = reader["Comment"].ToString(),
                    };

                    categorisedCheckPoints.Add(new KeyValuePair <string, CheckPoints>(Category, pts));
                    SelectedPointsList.Add(pts);
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                con.Close();
            }
            return(categorisedCheckPoints);
        }
Пример #21
0
        public void CreateCheckPoint(
            long timeStamp,
            IImmutableList <Block>?idsBlocks,
            IImmutableList <Block>?sprocsBlocks,
            IImmutableList <Block>?functionsBlocks,
            IImmutableList <Block>?triggersBlocks)
        {
            var checkpoint = new LogCheckPoint
            {
                TimeStamp       = timeStamp,
                DocumentBatches = InProgressDocumentBatches,
                IdsBlocks       = idsBlocks,
                SprocsBlocks    = sprocsBlocks,
                FunctionsBlocks = functionsBlocks,
                TriggersBlocks  = triggersBlocks
            };

            CheckPoints = CheckPoints.Add(checkpoint);
            InProgressDocumentBatches = InProgressDocumentBatches.Clear();
        }
Пример #22
0
        public List <KeyValuePair <string, CheckPoints> > CheckPointsList()
        {
            // string category = "";
            List <CheckPoints> SelectedPointsList = new List <CheckPoints>();
            string             Category           = "";
            var categorisedCheckPoints            = new List <KeyValuePair <string, CheckPoints> >();

            con.Open();
            try
            {
                string        str    = "select Check_Id, Category, Check_Points from QC_Check_Points";
                SqlCommand    cmd    = new SqlCommand(str, con);
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    Category = reader["Category"].ToString();
                    CheckPoints pts = new CheckPoints()
                    {
                        Check_Id     = Convert.ToInt32(reader["Check_Id"]),
                        Category     = reader["Category"].ToString(),
                        Check_Points = reader["Check_Points"].ToString(),
                    };
                    categorisedCheckPoints.Add(new KeyValuePair <string, CheckPoints>(Category, pts));
                    SelectedPointsList.Add(pts);
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                con.Close();
            }
            return(categorisedCheckPoints);
        }
Пример #23
0
 public void Update()
 {
     checkPoints = GameObject.FindObjectOfType <CheckPoints>();
 }
Пример #24
0
    static void Main(string[] args)
    {
        int[] inputs;
        var   pods        = Enumerable.Range(0, 4).Select(x => new Pod()).ToArray();
        var   checkPoints = new CheckPoints();

        var laps            = ReadInts()[0];
        var checkPointCount = ReadInts()[0];

        for (var i = 0; i < checkPointCount; i++)
        {
            inputs = ReadInts();
            checkPoints.Add(inputs[0], inputs[1]);
        }

        while (true)
        {
            for (var i = 0; i < 4; i++)
            {
                inputs = ReadInts();

                pods[i].Point = new Vector(inputs[0], inputs[1]);
                pods[i].Speed = new Vector(inputs[2], inputs[3]);
                pods[i].Angle = inputs[4];
                var nextCheckPoint = checkPoints.Get(inputs[5]);
                if (nextCheckPoint != pods[i].NextCheckPoint)
                {
                    pods[i].NextCheckPoint = nextCheckPoint;
                    pods[i].Checked++;
                }
            }

            for (var i = 0; i < 2; i++)
            {
                var v          = pods[i].NextCheckPoint - pods[i].Point;
                var speedAngle = pods[i].Speed.DiffAngle(v);

                var thrust = "100";

                var target = new Vector(pods[i].NextCheckPoint);
                if (Math.Abs(speedAngle) < 90)
                {
                    RotatePoint(target, pods[i].Point, speedAngle);
                }
                else
                {
                    var nextCheckpointAngle = pods[i].DiffSteerAngle(pods[i].NextCheckPoint);
                    var dist = pods[i].Point.GetDistance(pods[i].NextCheckPoint);
                    D(nextCheckpointAngle, dist);

                    if (dist < 1000 && Math.Abs(nextCheckpointAngle) > 45)
                    {
                        thrust = "0";
                    }
                }

                if (!pods[0].BoostUsed)
                {
                    pods[0].BoostUsed = true;
                    thrust            = "BOOST";
                }

                Console.WriteLine($"{target.X} {target.Y} {thrust}");
            }
        }
    }
Пример #25
0
        public void HandleClient(TcpClient client)
        {
            try
            {
                try
                {
                    while (true)
                    {
                        Block block = BlockChain.Instance.NextBlock("GPUMINE---", Node.Instance.NodeKey);

                        var     header  = block.GetBlockHeaderForHash();
                        JObject message = new JObject
                        {
                            new JProperty("method", "miner-notify"),
                            new JProperty("id", null)
                        };
                        Hash    h       = header.MinerPayload;
                        JObject jObject = new JObject
                        {
                            new JProperty("block", block.BlockNumber),
                            new JProperty("part1", (string)header.Part1),
                            new JProperty("part3", (string)header.Part3),
                            new JProperty("payload_start", (string)h),
                            new JProperty("version", 2),
                            new JProperty("timestamp", (uint)block.Timestamp),
                            new JProperty("target", block.CompactTarget),
                            new JProperty("target_pow", (string)BlockChain.TargetFromCompact(block.CompactTarget))
                        };
                        var param = new JArray
                        {
                            jObject
                        };
                        message.Add(new JProperty("params", param));
                        using (var ms = new MemoryStream())
                        {
                            ByteString json = message.ToString(Formatting.None) + Environment.NewLine;
#if !NETCOREAPP
                            Log.InfoFormat("Sending \"{0}\" to miner", json);
#endif
                            ms.Write(json, 0, json.Length);
                            ms.Position = 0;
                            ms.CopyTo(client.GetStream());
                            client.GetStream().Flush();
                        }

                        int timeout = 60000;
                        int i       = 0;
                        while (client.Available == 0)
                        {
                            Thread.Sleep(1);
                            if (Stop)
                            {
                                return;
                            }
                            i++;
                            if (i > timeout)
                            {
                                break;
                            }
                        }
                        using (MemoryStream buffer = new MemoryStream())
                        {
                            while (client.Available > 0)
                            {
                                byte[] b = new byte[client.Available];
                                client.GetStream().Read(b, 0, client.Available);
                                buffer.Write(b, 0, b.Length);
                            }
                            if (buffer.Length > 0)
                            {
                                ByteString response = buffer.ToArray();
#if !NETCOREAPP
                                Log.Info(response);
#endif
                                JObject minerResponse = JObject.Parse(response);
                                if (minerResponse.Value <string>("method") == "miner-submit")
                                {
                                    var br = new NewBlockRequest();
                                    br.Block             = block;
                                    br.Block.Nonce       = minerResponse.Value <JArray>("params").Value <JObject>(0).Value <int>("nonce");
                                    br.Block.Timestamp   = minerResponse.Value <JArray>("params").Value <JObject>(0).Value <uint>("timestamp");
                                    br.Block.ProofOfWork = br.Block.CalcProofOfWork();
                                    if (!br.Block.ProofOfWorkIsValid())
                                    {
#if !NETCOREAPP
                                        Log.Warn("Received invalid solution for block");
#endif
                                        continue;
                                    }
                                    byte[] targetPow = BlockChain.TargetFromCompact(block.CompactTarget);
                                    byte[] pow       = block.ProofOfWork;
                                    i = 0;
                                    bool found = false;
                                    foreach (byte c in pow)
                                    {
                                        i++;
                                        if ((byte)c == (byte)targetPow[i])
                                        {
                                            continue;
                                        }
                                        if ((byte)c < (byte)targetPow[i])
                                        {
                                            found = true;
                                            break;
                                        }
                                        break;
                                    }
                                    if (!found)
                                    {
#if !NETCOREAPP
                                        Log.Warn("Received invalid solution for block. PoW not valid");
#endif
                                        continue;
                                    }
#if !NETCOREAPP
                                    Log.Info("Received valid solution for block");
#endif
                                    BlockChain.Instance.AppendAll(new List <Block>()
                                    {
                                        br.Block
                                    });
                                    CheckPoints.AppendBlock(br.Block);
                                    Node.Instance.SendNewBlock(br.Block);
                                    Node.Instance.PendingTransactions.Clear();
                                }
                                else
                                {
                                }
                            }
                        }
                    }
                }
                catch
                {
                    return;
                }
            }
            finally
            {
                Clients.Remove(client);
                client.Dispose();
            }
        }
Пример #26
0
 void Awake()
 {
     drewBackTire = backTire.GetComponent <DrewBackTire>();
     checkPoints  = GetComponent <CheckPoints>();
     lapCounter   = lapController.GetComponent <LapController>();
 }
Пример #27
0
 private void FixedUpdate()
 {
     checkPoints        = GameObject.FindObjectOfType <CheckPoints>();
     transform.position = Vector3.Lerp(transform.position, checkPoints.gObject.transform.position, damping) + offset;
 }
Пример #28
0
 public void moveMyPlayer(CheckPoints ch, TransportType type)
 {
     setSelected(false);
     StartCoroutine(moveToPlace(currentCheck, ch, type));
 }
Пример #29
0
 public void initThiefPlayer(CheckPoints ch, ThiefUIController c, int ind)
 {
     thiefController = c;
     controller      = thiefController;
     initMyPlayer(ch, Character.Thief, ind);
 }
Пример #30
0
 public void initPolicePlayer(CheckPoints ch, PoliceUIController c, int ind)
 {
     policeController = c;
     controller       = policeController;
     initMyPlayer(ch, Character.Police, ind);
 }