Exemple #1
0
 protected override string ProcessChange()
 {
     if (this.templateNode.Name.ToLower() == "random")
     {
         if (this.templateNode.HasChildNodes)
         {
             // only grab <li> nodes
             List<XmlNode> listNodes = new List<XmlNode>();
             foreach (XmlNode childNode in this.templateNode.ChildNodes)
             {
                 if (childNode.Name == "li")
                 {
                     listNodes.Add(childNode);
                 }
             }
             if (listNodes.Count > 0)
             {
                 Random r = new Random();
                 XmlNode chosenNode = (XmlNode)listNodes[r.Next(listNodes.Count)];
                 return chosenNode.InnerXml;
             }
         }
     }
     return string.Empty;
 }
        /// <summary>
        /// Generate a tree with a given segment ID.
        /// </summary>
        /// <param name="depth">The depth of the tree.</param>
        /// <param name="maxChildren">The maximum number of children nodes allowed.</param>
        /// <param name="maxValue"> The maximum value allowed for the node's metrics.</param>
        /// <param name="segmentID">The ID to segment to which the leaves belong.</param>
        /// <param name="name">The name of the node (for making node names).</param>
        /// <param name="random">A random number generator for controlling tree generation.</param>
        /// <returns>A SegmentNode representing the root of the tree.</returns>
        private SegmentNode GenerateTree(int depth, int maxChildren, int maxValue, int segmentID, string name, Random random)
        {
            SegmentNode node = new SegmentNode();
            node.Name = name;

            if (depth <= 0)
            {
                node.Value = random.Next(1, maxValue);
                node.Value2 = random.Next(1, maxValue);
                node.Segment = segmentID;
                node.Children = new SegmentNode[0];
            }
            else
            {
                int numChildren = random.Next(2, maxChildren);
                
                node.Children = new List<SegmentNode>();
                for (int i = 0; i < numChildren; i++)
                {
                    node.Children.Add(GenerateTree(depth - 1, maxChildren, maxChildren, segmentID, name + "." + i, random));
                }
            }

            return node;
        }
Exemple #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string folderpath = @"/var/www/weavver.com/messages";
          if (!Directory.Exists(folderpath))
              return;

          XmlTextWriter writer    = new XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8);
          writer.Indentation      = 5;
          writer.Formatting       = Formatting.Indented;
          WriteRSSPrologue(writer);
          int i = 0;

          Random r = new Random(10);
          foreach (string file in System.IO.Directory.GetFiles(folderpath))
          {
               if (file.EndsWith("wav"))
               {
                    string num = r.Next(10).ToString() + r.Next(10).ToString() + r.Next(10).ToString() + "-" + r.Next(10).ToString() + r.Next(10).ToString() + r.Next(10).ToString() + r.Next(10).ToString();
                    AddRSSItem(writer, "Jane Doe left you a message from 714-" + num, file, System.IO.Path.GetFileName(file), DateTime.Now.Subtract(TimeSpan.FromDays(i)).ToString("r"));
                    i++;
               }
               if (i > 10)
               {
                    break;
               }
          }
          WriteRSSClosing(writer);
          writer.Flush();
          writer.Close();

          Response.ContentEncoding = System.Text.Encoding.UTF8;
          Response.ContentType     = "text/xml";
          Response.Cache.SetCacheability(HttpCacheability.Private);
          Response.End();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        n = Convert.ToInt32(Session["n"]);//Convert.ToInt32(n_txt.Text);
        dx = Convert.ToInt32(Session["dx"]);//Convert.ToInt32(n_txt.Text);
        dy = Convert.ToInt32(Session["dy"]);//Convert.ToInt32(n_txt.Text);
        npow = Convert.ToInt32(Math.Pow(2, n));
        boxes = new int[npow, npow,2];
        //if (!IsPostBack)
        {
            if (Session["create"].ToString() != "1")
            {
                Random rnd = new Random();
                for (int i = 0; i <= boxes.GetUpperBound(0); i++)
                {
                    for (int k = 0; k <= boxes.GetUpperBound(1); k++)
                    {
                        boxes[i, k, 0] = rnd.Next(1, 6);
                    }
                }
            }
            else
            {
               
                CreateBoxes(true, 0, 0, boxes.GetUpperBound(0), boxes.GetUpperBound(1),dx,dy);
            }

            fillBoxPanel();
        }

    }
    public static string AutoGeneratedPassword(string sEMail)
    {
        string sRondomPassword;

        sRondomPassword = string.Empty;
        Random oRandom = new Random();

        //  6 Characters Password...
        for (int iRunner = 0; iRunner < 6; iRunner++)
        {
            int iRandom = oRandom.Next(0, 61);
            sRondomPassword = sRondomPassword + PassChars.Substring(iRandom, 1);
        }

        //  Get PassKey from Session
        string sPassKey = PassKey;

        //  Get Encrypted Password...
        //string sCryptedPassword = CreatePasswordHash(sPassword);

        object ErrorMessage;
        UserInfo oUser = new UserInfo();

        bool UserCreated = oUser.ResetSiteUserPassword(sEMail, sRondomPassword, out ErrorMessage);
        oUser = null;

        //  Function Returning New Password
        return sRondomPassword;
    }
    public static void Main()
    {
        Stopwatch watch = new Stopwatch();
        Random rand = new Random();
        watch.Start();
        for (int i = 0; i < iterations; i++)
            DayOfYear1(rand.Next(1, 13), rand.Next(1, 29));
        watch.Stop();
        Console.WriteLine("Local array: " + watch.Elapsed);
        watch.Reset();
        watch.Start();
        for (int i = 0; i < iterations; i++)
            DayOfYear2(rand.Next(1, 13), rand.Next(1, 29));
        watch.Stop();
        Console.WriteLine("Static array: " + watch.Elapsed);

        // trying to modify static int []
        daysCumulativeDays[0] = 18;
        foreach (int days in daysCumulativeDays)
        {
            Console.Write("{0}, ", days);
        }
        Console.WriteLine("");

        // MY_STR_CONST = "NOT CONST";
    }
Exemple #7
0
 // Function to generate random string with Random class.
 private string GenerateRandomCode()
 {
     Random r = new Random();
     string s = "";
     for (int j = 0; j < 5;j++)
     {
         int i = r.Next(3);
         int ch;
         switch (i)
         {
             case 1:
                 ch = r.Next(0, 9);
                 s = s + ch.ToString();
                 break;
             case 2:
                 ch = r.Next(65, 90);
                 s = s + Convert.ToChar(ch).ToString();
                 break;
             case 3:
                 ch = r.Next(97, 122);
                 s = s + Convert.ToChar(ch).ToString();
                 break;
             default:
                 ch = r.Next(97, 122);
                 s = s + Convert.ToChar(ch).ToString();
                 break;
         }
         r.NextDouble();
         r.Next(100, 1999);
     }
     return s;
 }
Exemple #8
0
    public bool PosTest2()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest2: Verify Double value not equals with Equals(Double).");

        try
        {
            Random random = new Random(-55);
            Double d1,d2;
            do
            {
                d1 = random.NextDouble();
                d2 = random.NextDouble();
            }
            while (d1 == d2);

            if (d1.Equals(d2))
            {
                TestLibrary.TestFramework.LogError("002.1", "Method Double.Equals(Double) Err.");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002.2", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return retVal;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        OpenFlashChart.OpenFlashChart chart = new OpenFlashChart.OpenFlashChart();
        chart.Title=new Title("AreaHollow");

        AreaHollow area = new AreaHollow();
        Random random=new Random();
        area.Colour = "#0fe";
        area.DotSize = 2;
        area.FillAlpha = 0.4;
        area.Text = "Test";
        area.Width = 2;
        area.FontSize = 10;
        IList values = new List<double>();
        for (int i = 0; i < 12; i++)
            values.Add(random.Next(i, i*2));
        area.Values = values;
        chart.AddElement(area);
         XAxis xaxis=new XAxis();
           // xaxis.Labels = new AxisLabel("text","#ef0",10,"vertical");
        xaxis.Steps = 1;
        xaxis.SetRange(0,12);
        chart.X_Axis = xaxis;
        YAxis yaxis = new YAxis();
        yaxis.Steps = 4;
           yaxis.SetRange(0,20);
        chart.Y_Axis = yaxis;
        string s = chart.ToString();
        Response.Clear();
        Response.CacheControl = "no-cache";
        Response.Write(s);
        Response.End();
    }
Exemple #10
0
        public static void SetRandomEdge(Vertex[] vertices)
        {
            bool found = false;
            int i = 0;
            int j = 0;

            int count = 0;
            Random random = new Random();

            for (int k = 0; k < vertices.Length; k++)
            {
                for(int l = 0; l < vertices.Length; l++)
                {
                    if (k == l || vertices[k].Vertices.Any(v => v == vertices[l]))
                        continue;

                    count++;
                    if(random.Next(0, count) == 0)
                    {
                        i = k;
                        j = l;
                        found = true;
                    }
                }
            }

            if (found)
                vertices[i].AddDirectedEdge(vertices[j]);
        }
Exemple #11
0
    public bool PosTest1()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest1: Verify Double value equals with Equals(Double).");

        try
        {
            Double d1 = new Random(-55).NextDouble();
            Double d2 = d1;

            if (!d1.Equals(d2))
            {
                TestLibrary.TestFramework.LogError("001.1", "Method Double.Equals(Double) Err.");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("001.2", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return retVal;
    }
Exemple #12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //加载页面时初始化支付需要的业务明文参数

        orderAmount.Text = "2";//默认的交易金额

        Random ra = new Random();
        traderOrderID.Text = "1234567" + 50 * ra.Next();//商户订单号

        identityID.Text = "user_" + 50 * ra.Next();//用户身份标识
        identityType.Text = "2";//用户身份标识类型,0为IMEI,1为MAC,2为用户ID,3为用户Email,4为用户手机号,5为用户身份证号,6为用户纸质协议单号
        userIP.Text = getIp();//获取用户IP地址
        userUA.Text = Request.UserAgent;//获取用户UA

        terminalType.Text = "3";//终端类型,0、IMEI;1、MAC;2、UUID;3、other,如果终端类型未知的话,那么就传other
        terminalID.Text = "nothing";//终端类型未知,终端标识可以传任意字符串

        productCatalog.Text = "1";//1代表虚拟商品,商品类别必须与协议保持一致。商品类别编码请见http://mobiletest.yeepay.com/file/doc/pubshow?doc_id=14#hm_27。
        productName.Text = "玉米加农炮";//商品名称
        productDesc.Text = "植物大战僵尸道具";//商品描述

        fcallbackURL.Text = "http://mobiletest.yeepay.com/demo/pay/callback";//支付成功后商户前台提供的回调的地址,fcallbackURL.Text = "http://mobiletest.yeepay.com/demo/pay/callback";

        callbackURL.Text = "http://mobiletest.yeepay.com/demo/pay/callback";//支付成功后商户后台提供的回调的地址,fcallbackURL.Text = "http://mobiletest.yeepay.com/demo/pay/callback";
    }
Exemple #13
0
        public static void SetRandomEdge(int[,] graph, int n)
        {
            bool found = false;
            int i = 0;
            int j = 0;

            int count = 0;
            Random random = new Random();

            for (int k = 0; k < n; k++)
            {
                for (int l = 0; l < n; l++)
                {
                    if (graph[k, l] != int.MaxValue)
                        continue;

                    count++;

                    if (random.Next(0, count) == 0)
                    {
                        found = true;
                        i = k;
                        j = l;
                    }
                }
            }

            if (found)
                graph[i, j] = random.Next(1, 10);
        }
        public void reset()
        {
            Random random = new Random();
            int localtag = 0;
            localtag++;

            // TO TRIGGER THE BUG:
            // remove the itself from parent from an action
            // The menu will be removed, but the instance will be alive
            // and then a new node will be allocated occupying the memory.
            // => CRASH BOOM BANG
            CCNode node = getChildByTag(localtag - 1);
            CCLog.Log("Menu: %p", node);
            removeChild(node, false);
            //	[self removeChildByTag:localtag-1 cleanup:NO];

            CCMenuItem item1 = CCMenuItemFont.itemFromString("One", this, menuCallback);
            CCLog.Log("MenuItemFont: %p", item1);
            CCMenuItem item2 = CCMenuItemFont.itemFromString("Two", this, menuCallback);
            CCMenu menu = CCMenu.menuWithItems(item1, item2);
            menu.alignItemsVertically();

            float x = random.Next() * 50;
            float y = random.Next() * 50;
            menu.position = CCPointExtension.ccpAdd(menu.position, new CCPoint(x, y));
            addChild(menu, 0, localtag);

            //[self check:self];
        }
Exemple #15
0
    /// <summary>
    /// 生成手机密码:通过用户编号
    /// </summary>
    /// <param name="sUserNo">用户编号</param>
    /// <returns>已生成手机密码的用户的手机号</returns>
    public string GenerateSMP(string sUserNo)
    {
        Random r1 = new Random();
        int iRandomPassword;
        string sRandomPassword,SM_content,mobile_telephone,sOperCode;
        DataSet ds=new DataSet();

        //生成密码
        iRandomPassword = r1.Next(1000000);
        sRandomPassword = fu.PasswordEncode(iRandomPassword.ToString());
        ds = fu.GetOneUserByUserIndex(sUserNo);

        sOperCode = ds.Tables[0].Rows[0]["User_code"].ToString();
        mobile_telephone = ds.Tables[0].Rows[0]["mobile_telephone"].ToString();

        sSql = "UPDATE Frame_user SET SM_PWD='" + sRandomPassword + "',SMP_last_change_time=getdate()" +
                " WHERE User_code = '" + sOperCode + "'";
        sv.ExecuteSql(sSql);
        //发送密码

        string SMP_validity_period = ds.Tables[0].Rows[0]["SMP_validity_period"].ToString();
        SM_content = "欢迎您使用EBM系统!您新的手机密码是:" + iRandomPassword.ToString() + "有效时间为:" + SMP_validity_period + "小时。";
        SendSMContentByPhoneCode(mobile_telephone, SM_content);
        return mobile_telephone;
    }
Exemple #16
0
    private DataTable GetDataTable()
    {
        Random random = new Random();

        DataTable dt = new DataTable("Tabela Teste");
        dt.Columns.Add("ID", typeof(Int32));
        dt.Columns.Add("Número Inteiro", typeof(Int32));
        dt.Columns.Add("Número Double", typeof(Double));
        dt.Columns.Add("Descrição", typeof(String));
        dt.Columns.Add("Data", typeof(DateTime));

        for (int i = 0; i < 20; i++)
        {
            DataRow dr = dt.NewRow();

            dr["ID"] = i + 1;
            dr["Número Inteiro"] = random.Next();
            dr["Número Double"] = random.NextDouble();
            dr["Descrição"] = "sadsdadasd asd asd sa d";
            dr["Data"] = DateTime.Now;
            dt.Rows.Add(dr);
        }

        return dt;
    }
        private static JToken CreateJToken(Random rndGen, int depth)
        {
            if (rndGen.Next() < CreatorSettings.NullValueProbability)
            {
                return null;
            }

            if (depth < MaxDepth)
            {
                switch (rndGen.Next(10))
                {
                    case 0:
                    case 1:
                    case 2:
                        // 30% chance to create an array
                        return CreateJArray(rndGen, depth);
                    case 3:
                    case 4:
                    case 5:
                        // 30% chance to create an object
                        return CreateJObject(rndGen, depth);
                    default:
                        // 40% chance to create a primitive
                        break;
                }
            }

            return CreateJsonPrimitive(rndGen);
        }
Exemple #18
0
 public void Before() {
     _random = new Random();
     _l = new List<Entity>();
     for (int i = 0; i < n; i++) {
         _l.Add(new Entity(CP.NumComponents));
     }
 }
	public Item GetRandomTreasureItem(Random rnd)
	{
		if (drops == null)
		{
			drops = new List<DropData>();
			drops.Add(new DropData(itemId: 62004, chance: 10, amountMin: 1, amountMax: 2)); // Magic Powder
			drops.Add(new DropData(itemId: 51102, chance: 10, amountMin: 1, amountMax: 2)); // Mana Herb
			drops.Add(new DropData(itemId: 51003, chance: 10, amountMin: 1, amountMax: 2)); // HP 50 Potion
			drops.Add(new DropData(itemId: 51008, chance: 10, amountMin: 1, amountMax: 2)); // MP 50 Potion
			drops.Add(new DropData(itemId: 51013, chance: 10, amountMin: 1, amountMax: 2)); // Stamina 50 Potion
			drops.Add(new DropData(itemId: 71049, chance: 5, amountMin: 2, amountMax: 4)); // Snake Fomor Scroll
			drops.Add(new DropData(itemId: 63123, chance: 10, amount: 1, expires: 480)); // Ciar Intermediate Fomor Pass for One
			drops.Add(new DropData(itemId: 63124, chance: 10, amount: 1, expires: 480)); // Ciar Intermediate Fomor Pass for Two
			drops.Add(new DropData(itemId: 63125, chance: 10, amount: 1, expires: 480)); // Ciar Intermediate Fomor Pass for Four

			if (IsEnabled("CiarAdvanced"))
			{
				drops.Add(new DropData(itemId: 63136, chance: 5, amount: 1, expires: 360)); // Ciar Adv. Fomor Pass for 2
				drops.Add(new DropData(itemId: 63137, chance: 5, amount: 1, expires: 360)); // Ciar Adv. Fomor Pass for 3
				drops.Add(new DropData(itemId: 63138, chance: 5, amount: 1, expires: 360)); // Ciar Adv. Fomor Pass
			}
		}

		return Item.GetRandomDrop(rnd, drops);
	}
Exemple #20
0
        public static void RunTests(int seed)
        {
            Random random = new Random(seed);

            RunPositiveTests(random);
            RunNegativeTests(random);
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        var theData = new List<string>();

        Random rand = new Random();
        Response.Write("<br><br>Adding items to the list, ");
        for (int i = 0; i < 999; i++)
            theData.Add("Item" + (i + rand.Next(100)).ToString("0000"));

        Response.Write("<br><br>Finding " + theData[theData.Count / 2]);
        var findItem = from p in theData
                       where p == theData[theData.Count / 2]
                          select p;

        Response.Write(" : Found Total " + findItem.Count());

        Response.Write("<br><br>Listing First 10 Items: ");
        for (int i = 0; i < 10; i++)
            Response.Write(theData[i] + ", ");

        theData.Sort();
        Response.Write("<br><br>Listing First 10 Items after sort: ");
        for (int i = 0; i < 10; i++)
            Response.Write(theData[i] + ", ");
    }
Exemple #22
0
 public override async Task Run()
 {
     int itemId, amount;
     if (HasQuestStarted(2051))
     {
         itemId = 4031032;
         amount = 1;
     }
     else
     {
         int[] rewards = new[] {
             4020007, 2,
             4020008, 2,
             4010006, 2,
             1032013, 1
         };
         var rand = new Random();
         int index = rand.Next(rewards.Length / 2);
         itemId = rewards[index];
         amount = rewards[index + 1];
     }
     if (GainItem(itemId, amount))
     {
         SetField(101000000);
     }
     else
     {
         //TODO: Make more GMS-like.
         Talker.Notify("Please check whether your ETC. inventory is full.");
     }
 }
    // You are given an array of strings. Write a method
    // that sorts the array by the length of its elements
    // (the number of characters composing them).

    static void Main()
    {
        //variables
        string[] array = new string[7];
        Random rand = new Random();

        //fill the Array with Random strings
        for (int i = 0; i < array.Length; i++)
        {
            string member = null;
            for (int k = 0; k < rand.Next(1, 7); k++)     //length of strings
            {
                member = member + RandomString();
            }
            array[i] = member;
        }

        #region print original array
        Console.Write("{");
        Console.Write(String.Join(", ", array));
        Console.WriteLine("} -> ");
        #endregion

        //sort the array by the length of its elements
        var SortedArray = array.OrderBy(x => x.Length);     //using Linq

        #region print sorted array
        Console.Write("{");
        Console.Write(String.Join(", ", SortedArray));
        Console.WriteLine("} ");
        #endregion
    }
Exemple #24
0
    /// <summary>
    /// ����ͼƬ
    /// </summary>
    /// <param name="checkCode">�����</param>
    private void CreateImage(string checkCode)
    {
        int iwidth = (int)(checkCode.Length * 11.5);//����������趨ͼƬ���
        Bitmap image = new Bitmap(iwidth, 20);//����һ������
        Graphics g = Graphics.FromImage(image);//�ڻ����϶����ͼ��ʵ��
        Font f = new Font("Arial",10,FontStyle.Bold);//���壬��С����ʽ
        Brush b = new SolidBrush(Color.Black);//������ɫ
        //g.FillRectangle(new System.Drawing.SolidBrush(Color.Blue),0,0,image.Width, image.Height);
        g.Clear(Color.White);//������ɫ
        g.DrawString(checkCode, f, b, 3, 3);

        Pen blackPen = new Pen(Color.Black, 0);
        Random rand = new Random();
        /*�����
        for (int i = 0; i < 5; i++)
        {
            int y = rand.Next(image.Height);
            g.DrawLine(blackPen, 0, y, image.Width, y);
        }
        */
        System.IO.MemoryStream ms = new System.IO.MemoryStream();
        image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
        Response.ClearContent();
        Response.ContentType = "image/Jpeg";
        Response.BinaryWrite(ms.ToArray());
        g.Dispose();
        image.Dispose();
    }
Exemple #25
0
        public void MultipleAnnounce()
        {
            var announceCount = 0;
            var random = new Random();
            var handle = new ManualResetEvent(false);

            for (var i = 0; i < 20; i++)
            {
                var infoHash = new InfoHash(new byte[20]);
                random.NextBytes(infoHash.Hash);
                var tier = new TrackerTier(new[] {_uri.ToString()});
                tier.Trackers[0].AnnounceComplete += (sender, args) =>
                                                         {
                                                             if (++announceCount == 20)
                                                                 handle.Set();
                                                         };
                var id = new TrackerConnectionID(tier.Trackers[0], false, TorrentEvent.Started,
                                                 new ManualResetEvent(false));
                var parameters = new OctoTorrent.Client.Tracker.AnnounceParameters(0, 0, 0, TorrentEvent.Started,
                                                                                   infoHash, false, new string('1', 20),
                                                                                   string.Empty, 1411);
                tier.Trackers[0].Announce(parameters, id);
            }

            Assert.IsTrue(handle.WaitOne(5000, true), "Some of the responses weren't received");
        }
    static string[] RandomStringArray()
    {
        Random rand = new Random();
        int len = rand.Next(3, 10); // [3;10)
        string[] stringArr = new string[len];

        // let's build the words observing the frequency of the letters in English
        // so for example the vowels will appear more often
        // http://www.oxforddictionaries.com/words/what-is-the-frequency-of-the-letters-of-the-alphabet-in-english
        double[] frequencies = { 0.002, 0.004, 0.007, 0.010, 0.020, 0.031, 0.044, 0.061, 0.079, 0.100, 0.125, 0.155, 0.185, 0.217, 0.251, 0.287, 0.332, 0.387, 0.444, 0.511, 0.581, 0.652, 0.728, 0.803, 0.888, 1.000, };
        char[] letters = { 'q', 'j', 'z', 'x', 'v', 'k', 'w', 'y', 'f', 'b', 'g', 'h', 'm', 'p', 'd', 'u', 'c', 'l', 's', 'n', 't', 'o', 'i', 'r', 'a', 'e', };

        for (int i = 0; i < len; i++)
        {
            int wordLen = rand.Next(1, 10); // determines the length of the current string
            string word = string.Empty;
            for (int j = 0; j < wordLen; j++)
            {
                double frequency = rand.Next(2, 1000) / 1000d; // [0.002;0.999]
                int index = Array.BinarySearch(frequencies, frequency);
                if (index < 0) index = ~index;
                char letter = letters[index];
                word += letter;
            }
            stringArr[i] = word;
        }
        return stringArr;
    }
Exemple #27
0
    public Item GetRandomTreasureItem(Random rnd)
    {
        if (drops == null)
        {
            drops = new List<DropData>();
            drops.Add(new DropData(itemId: 62004, chance: 15, amountMin: 1, amountMax: 2)); // Magic Powder
            drops.Add(new DropData(itemId: 51102, chance: 15, amountMin: 1, amountMax: 2)); // Mana Herb
            drops.Add(new DropData(itemId: 51003, chance: 15, amountMin: 1, amountMax: 2)); // HP 50 Potion
            drops.Add(new DropData(itemId: 51008, chance: 15, amountMin: 1, amountMax: 2)); // MP 50 Potion
            drops.Add(new DropData(itemId: 51013, chance: 15, amountMin: 1, amountMax: 2)); // Stamina 50 Potion
            drops.Add(new DropData(itemId: 71049, chance: 4, amountMin: 2, amountMax: 5)); // Snake Fomor Scroll
            drops.Add(new DropData(itemId: 63104, chance: 4, amount: 1, expires: 600)); // Ciar Basic Fomor Pass
            drops.Add(new DropData(itemId: 63123, chance: 3, amount: 1, expires: 480)); // Ciar Intermediate Fomor Pass for One
            drops.Add(new DropData(itemId: 63124, chance: 3, amount: 1, expires: 480)); // Ciar Intermediate Fomor Pass for Two
            drops.Add(new DropData(itemId: 63125, chance: 3, amount: 1, expires: 480)); // Ciar Intermediate Fomor Pass for Four
            drops.Add(new DropData(itemId: 40015, chance: 1, amount: 1, color1: 0xFFDB60, durability: 0)); // Fluted Short Sword (gold)

            if (IsEnabled("CiarAdvanced"))
            {
                drops.Add(new DropData(itemId: 63136, chance: 5, amount: 1, expires: 360)); // Ciar Adv. Fomor Pass for 2
                drops.Add(new DropData(itemId: 63137, chance: 5, amount: 1, expires: 360)); // Ciar Adv. Fomor Pass for 3
                drops.Add(new DropData(itemId: 63138, chance: 5, amount: 1, expires: 360)); // Ciar Adv. Fomor Pass
            }
        }

        return Item.GetRandomDrop(rnd, drops);
    }
Exemple #28
0
    // guessGame receives user input and returns output
    // based on their guess.
    private static void GuessGame(object obj)
    {
        var client = (TcpClient)obj;
        NetworkStream stream = client.GetStream();
        StreamReader streamR = new StreamReader(stream);
        StreamWriter streamW = new StreamWriter(stream);
        streamW.AutoFlush = true;

        string input;
        int guess = 0;
        int guesses = 0;
        int num = new Random().Next(1, 101);

        try {
            streamW.WriteLine("+ Hello. I'm thinking of a number between 1 and 100. Can you guess it?");
            while(guess != num) {
                input = streamR.ReadLine();
                guesses++;
                if (!int.TryParse(input, out guess) || (guess < 1 || guess > 100)) {
                    guesses--;
                    streamW.WriteLine("! Invalid input, please enter only numbers between 1 and 100.");
                } else if (guess < num) {
                    streamW.WriteLine("> Higher.");
                } else if (guess > num) {
                    streamW.WriteLine("< My number is lower.");
                }
            }
            streamW.WriteLine("* That's it. Good job. It took you {0} guesses. Thanks for playing.", guesses);
            stream.Close();
        } catch (Exception) {
            stream.Close();
            return;
        }
    }
Exemple #29
0
    protected void BtnAdd_Click(object sender, EventArgs e)
    {
        SqlConnection vid = new SqlConnection("Data Source=(local);Initial Catalog=Ring;Integrated Security=True");
        {
            Random rnd = new Random();
            SqlCommand orders = new SqlCommand("INSERT INTO dbo.orders (email,order_ID,month,year,jewel_ID,price,credit_Card) VALUES (@email,@order_ID,@month,@year,@jewel_ID,@price,@credit_Card)", vid);
            orders.Parameters.AddWithValue("@email", Session["username"]);
            int holder = rnd.Next(10000000,99999999);
            orders.Parameters.AddWithValue("@price", ddlPrice.Text);
            orders.Parameters.AddWithValue("@jewel_ID", ddlJewel.Text);
            holder = rnd.Next(10000000, 99999999);
            orders.Parameters.AddWithValue("@order_ID", holder.ToString());
            orders.Parameters.AddWithValue("@month", DateTime.Now.Month.ToString());
            orders.Parameters.AddWithValue("@year", DateTime.Now.Year.ToString());
            holder = rnd.Next(10000000, 99999999);
            orders.Parameters.AddWithValue("@credit_Card", holder.ToString());
            holder = rnd.Next(10000000, 99999999);
            SqlCommand inventory = new SqlCommand("UDATE dbo.Inventory SET jewel_ID='"+holder+"'WHERE jewel_ID='"+ ddlJewel.Text+"'", vid);
            vid.Open();

            orders.ExecuteNonQuery();
            inventory.ExecuteNonQuery();
            vid.Close();

            if (IsPostBack)
            {
                Server.Transfer("Account.aspx", true);
            }
        }
    }
    public static ProductsModel GetRandomPro()
    {
        ProductsModel pro = new ProductsModel();
        try
        {

            using (DataContentDataContext dc = new DataContentDataContext())
            {
                var items = (from temp in dc.Products
                             select temp);
                int count = items.Count(); // 1st round-trip
                int index = new Random().Next(count);
                Product i = items.Skip(index).FirstOrDefault();
                ProductsModel p = new ProductsModel(i.Id, i.Header, i.Name, i.Descrition, i.Price, i.Link_Image_Small, i.Link_Image, i.Creater, i.CreateDate, i.Modifier, i.ModifyDate);
                pro = p;

            }
            return pro;
        }
        catch (Exception)
        {
            return pro;

        }
    }
Exemple #31
0
 private Vector3 Spread()
 {
     return (new Vector3(Random.Range(-this._spreadAngle.Value, this._spreadAngle.Value),
         Random.Range(-this._spreadAngle.Value, this._spreadAngle.Value),
         Random.Range(-this._spreadAngle.Value, this._spreadAngle.Value)));
 }
    IEnumerator enemyTurn()
    {
        beingHandled = true;
        if (normal)
        {
            CmdOnEnemyHealthChanged(10);
        }
        else if (magic)
        {
            CmdOnEnemyHealthChanged(20);
        }

        if (int.Parse(enemyHealth2Text.text) <= 0)
        {
            enemyHealth = 0;
            enemyHealthText.text = enemyHealth.ToString();
            if (Collision.normalCollide && !normalDefeated)
            {
                normalDefeated = true;
                Collision.normalCollide = false;
            }

            if (Collision.bossCollide && !bossDefeated)
            {

                bossDefeated = true;
                Collision.bossCollide = false;
            }

            turn = pName + ":Enemy defeated!";
            CmdOnTurnChanged(turn);

            yield return new WaitForSeconds(2);

            if (bossDefeated)
                NetworkManager.singleton.ServerChangeScene("MainMenu");

            if (isServer)
            {
                RpcChangeToMove();
            }

            CmdOnCanvasChanged(false);


        }
        else
        {

            yield return new WaitForSeconds(1);

            turn = pName + ":Enemy Turn";
            CmdOnTurnChanged(turn);
            int State = Random.Range(0, 2);
            int hitChance = 0;
            if (pass)
                hitChance = Random.Range(0, 4);
            else
                hitChance = Random.Range(0, 2);
            yield return new WaitForSeconds(1);

            if (hitChance == 1)
            {
                if (State == 1)
                {
                    if (enemyEnergy >= ENEMY_MAGIC_CONSUME)
                    {
                        turn = pName + ":Eenmy used magical attack";

                        CmdOnPlayerHealthChanged(20);

                        CmdOnEnemyEnergyChanged(ENEMY_MAGIC_CONSUME);
                        if (enemyEnergy <= 0)
                        {
                            enemyEnergy = 0;
                        }
                    }
                }
                else
                {
                    turn = pName + ":Enemy used normal attack";

                    CmdOnPlayerHealthChanged(5);

                }
            }

            CmdOnTurnChanged(turn);
            yield return new WaitForSeconds(1);

            if (playerHealth <= 0)
            {
                turn = pName + ":you lose!";
                CmdOnTurnChanged(turn);
                CmdOnPlayerCountChanged();
                yield return new WaitForSeconds(2);
                NetworkManager.singleton.ServerChangeScene("MainMenu");
            }
            else
            {
                currentState = BattleStates.PLAYERCHOICE;
            }
        }

        currentState = BattleStates.PLAYERCHOICE;
        beingHandled = false;
        turn = pName + ":Your Turn";
        CmdOnTurnChanged(turn);
        CmdOnResetCount();
        count = playerCount;
        countText.text = count.ToString();
        turnChoosed = false;
    }
 public void SpawnRand()
 {
     float randomAngle = Random.Range(0f, 360f);
     Vector3 spawn = Quaternion.Euler(0, 0, randomAngle) * new Vector3(0, 1, 0) * 15f;
     GameObject obj = Instantiate(spawnObject[Random.Range(0, spawnObject.Length-1)], spawn, Quaternion.identity);
 }
 public void SpawnWall(bool vertical)
 {
     GameObject wall = Instantiate(walls[Random.Range(0, walls.Length - 1)], Vector3.one * 50f, Quaternion.identity);
     wall.GetComponent<WallSlam>().horizontal = !vertical;
 }
    private IEnumerator SpawnUsersRoutine()
    {
        while (_waveController.SpawnedUsers < _waveController.CurrentWaveCount + 4)
        {
            _timer += Time.deltaTime;

            if (_timer >= _waitTime)
            {
                _timer = 0;
                SpawnUserWithRandomValues(_runner);
                _runner   = false;
                _waitTime = Random.Range(_randomMin, _randomMax);

                if (_scoreManager.CurrentScore > 10000)
                {
                    _randomMin = 0.5f;
                    _randomMax = 2f;
                    _runner    = true;
                }
                else if (_scoreManager.CurrentScore > 9000)
                {
                    _randomMin    = 1f;
                    _randomMax    = 2.5f;
                    _runnerChance = Random.Range(0, 100);
                    if (_runnerChance < 90)
                    {
                        _runner = true;
                    }
                }
                else if (_scoreManager.CurrentScore > 7500)
                {
                    _randomMin    = 1.5f;
                    _randomMax    = 2.5f;
                    _runnerChance = Random.Range(0, 100);
                    if (_runnerChance < 70)
                    {
                        print(_runner);
                        _runner = true;
                    }
                    print(_runner);
                }
                else if (_scoreManager.CurrentScore > 5000)
                {
                    _randomMin    = 1f;
                    _randomMax    = 3f;
                    _runnerChance = Random.Range(0, 100);
                    if (_runnerChance < 50)
                    {
                        _runner = true;
                    }
                }
                else if (_scoreManager.CurrentScore > 3000)
                {
                    _randomMin    = 1.5f;
                    _randomMax    = 3.0f;
                    _runnerChance = Random.Range(0, 100);
                    if (_runnerChance < 35)
                    {
                        _runner = true;
                    }
                }
                else if (_scoreManager.CurrentScore > 1000)
                {
                    _randomMin    = 2f;
                    _randomMax    = 4f;
                    _runnerChance = Random.Range(0, 100);
                    if (_runnerChance < 25)
                    {
                        _runner = true;
                    }
                }
            }
            yield return(null);
        }
    }
Exemple #36
0
 void playEnemySound()
 {
     playOnce(enemySounds [Random.Range(0, enemySounds.Length)]);
 }
Exemple #37
0
        private void ProcessCommAlarmACS(ref CHCNetSDK.NET_DVR_ALARMER pAlarmer, IntPtr pAlarmInfo, uint dwBufLen, IntPtr pUser)
        {
            CHCNetSDK.NET_DVR_ACS_ALARM_INFO struAcsAlarmInfo = new CHCNetSDK.NET_DVR_ACS_ALARM_INFO();
            struAcsAlarmInfo = (CHCNetSDK.NET_DVR_ACS_ALARM_INFO)Marshal.PtrToStructure(pAlarmInfo, typeof(CHCNetSDK.NET_DVR_ACS_ALARM_INFO));
            CHCNetSDK.NET_DVR_LOG_V30 struFileInfo = new CHCNetSDK.NET_DVR_LOG_V30();
            struFileInfo.dwMajorType = struAcsAlarmInfo.dwMajor;
            struFileInfo.dwMinorType = struAcsAlarmInfo.dwMinor;
            char[] csTmp = new char[256];

            if (CHCNetSDK.MAJOR_ALARM == struFileInfo.dwMajorType)
            {
                TypeMap.AlarmMinorTypeMap(struFileInfo, csTmp);
            }
            else if (CHCNetSDK.MAJOR_OPERATION == struFileInfo.dwMajorType)
            {
                TypeMap.OperationMinorTypeMap(struFileInfo, csTmp);
            }
            else if (CHCNetSDK.MAJOR_EXCEPTION == struFileInfo.dwMajorType)
            {
                TypeMap.ExceptionMinorTypeMap(struFileInfo, csTmp);
            }
            else if (CHCNetSDK.MAJOR_EVENT == struFileInfo.dwMajorType)
            {
                TypeMap.EventMinorTypeMap(struFileInfo, csTmp);
            }

            String szInfo    = new String(csTmp).TrimEnd('\0');
            String szInfoBuf = null;

            szInfoBuf = szInfo;
            /**************************************************/
            String name = System.Text.Encoding.UTF8.GetString(struAcsAlarmInfo.sNetUser).TrimEnd('\0');

            for (int i = 0; i < struAcsAlarmInfo.sNetUser.Length; i++)
            {
                if (struAcsAlarmInfo.sNetUser[i] == 0)
                {
                    name = name.Substring(0, i);
                    break;
                }
            }
            /**************************************************/

            szInfoBuf = string.Format("{0} time:{1,4}-{2:D2}-{3} {4:D2}:{5:D2}:{6:D2}, [{7}]({8})", szInfo, struAcsAlarmInfo.struTime.dwYear, struAcsAlarmInfo.struTime.dwMonth,
                                      struAcsAlarmInfo.struTime.dwDay, struAcsAlarmInfo.struTime.dwHour, struAcsAlarmInfo.struTime.dwMinute, struAcsAlarmInfo.struTime.dwSecond,
                                      struAcsAlarmInfo.struRemoteHostAddr.sIpV4, name);

            if (struAcsAlarmInfo.struAcsEventInfo.byCardNo[0] != 0)
            {
                szInfoBuf = szInfoBuf + "+Card Number:" + System.Text.Encoding.UTF8.GetString(struAcsAlarmInfo.struAcsEventInfo.byCardNo).TrimEnd('\0');
            }
            String[] szCardType = { "normal card", "disabled card", "blacklist card", "night watch card", "stress card", "super card", "guest card" };
            byte     byCardType = struAcsAlarmInfo.struAcsEventInfo.byCardType;

            if (byCardType != 0 && byCardType <= szCardType.Length)
            {
                szInfoBuf = szInfoBuf + "+Card Type:" + szCardType[byCardType - 1];
            }

            if (struAcsAlarmInfo.struAcsEventInfo.dwCardReaderNo != 0)
            {
                szInfoBuf = szInfoBuf + "+Card Reader Number:" + struAcsAlarmInfo.struAcsEventInfo.dwCardReaderNo;
            }
            if (struAcsAlarmInfo.struAcsEventInfo.dwDoorNo != 0)
            {
                szInfoBuf = szInfoBuf + "+Door Number:" + struAcsAlarmInfo.struAcsEventInfo.dwDoorNo;
            }
            if (struAcsAlarmInfo.struAcsEventInfo.dwVerifyNo != 0)
            {
                szInfoBuf = szInfoBuf + "+Multiple Card Authentication Serial Number:" + struAcsAlarmInfo.struAcsEventInfo.dwVerifyNo;
            }
            if (struAcsAlarmInfo.struAcsEventInfo.dwAlarmInNo != 0)
            {
                szInfoBuf = szInfoBuf + "+Alarm Input Number:" + struAcsAlarmInfo.struAcsEventInfo.dwAlarmInNo;
            }
            if (struAcsAlarmInfo.struAcsEventInfo.dwAlarmOutNo != 0)
            {
                szInfoBuf = szInfoBuf + "+Alarm Output Number:" + struAcsAlarmInfo.struAcsEventInfo.dwAlarmOutNo;
            }
            if (struAcsAlarmInfo.struAcsEventInfo.dwCaseSensorNo != 0)
            {
                szInfoBuf = szInfoBuf + "+Event Trigger Number:" + struAcsAlarmInfo.struAcsEventInfo.dwCaseSensorNo;
            }
            if (struAcsAlarmInfo.struAcsEventInfo.dwRs485No != 0)
            {
                szInfoBuf = szInfoBuf + "+RS485 Channel Number:" + struAcsAlarmInfo.struAcsEventInfo.dwRs485No;
            }
            if (struAcsAlarmInfo.struAcsEventInfo.dwMultiCardGroupNo != 0)
            {
                szInfoBuf = szInfoBuf + "+Multi Recombinant Authentication ID:" + struAcsAlarmInfo.struAcsEventInfo.dwMultiCardGroupNo;
            }
            if (struAcsAlarmInfo.struAcsEventInfo.byCardReaderKind != 0)
            {
                szInfoBuf = szInfoBuf + "+CardReaderKind:" + struAcsAlarmInfo.struAcsEventInfo.byCardReaderKind.ToString();
            }
            if (struAcsAlarmInfo.struAcsEventInfo.wAccessChannel >= 0)
            {
                szInfoBuf = szInfoBuf + "+wAccessChannel:" + struAcsAlarmInfo.struAcsEventInfo.wAccessChannel;
            }
            if (struAcsAlarmInfo.struAcsEventInfo.dwEmployeeNo != 0)
            {
                szInfoBuf = szInfoBuf + "+EmployeeNo:" + struAcsAlarmInfo.struAcsEventInfo.dwEmployeeNo;
            }
            if (struAcsAlarmInfo.struAcsEventInfo.byDeviceNo != 0)
            {
                szInfoBuf = szInfoBuf + "+byDeviceNo:" + struAcsAlarmInfo.struAcsEventInfo.byDeviceNo.ToString();
            }
            if (struAcsAlarmInfo.struAcsEventInfo.wLocalControllerID >= 0)
            {
                szInfoBuf = szInfoBuf + "+wLocalControllerID:" + struAcsAlarmInfo.struAcsEventInfo.wLocalControllerID;
            }
            if (struAcsAlarmInfo.struAcsEventInfo.byInternetAccess >= 0)
            {
                szInfoBuf = szInfoBuf + "+byInternetAccess:" + struAcsAlarmInfo.struAcsEventInfo.byInternetAccess.ToString();
            }
            if (struAcsAlarmInfo.struAcsEventInfo.byType >= 0)
            {
                szInfoBuf = szInfoBuf + "+byType:" + struAcsAlarmInfo.struAcsEventInfo.byType.ToString();
            }
            if (struAcsAlarmInfo.struAcsEventInfo.bySwipeCardType != 0)
            {
                szInfoBuf = szInfoBuf + "+bySwipeCardType:" + struAcsAlarmInfo.struAcsEventInfo.bySwipeCardType.ToString();
            }
            //其它消息先不罗列了......

            if (struAcsAlarmInfo.dwPicDataLen > 0)
            {
                path = null;
                Random rand = new Random(unchecked ((int)DateTime.Now.Ticks));
                path = string.Format(@"C:/Picture/ACS_LocalTime{0}_{1}.bmp", szInfo, rand.Next());
                using (FileStream fs = new FileStream(path, FileMode.Create))
                {
                    int    iLen = (int)struAcsAlarmInfo.dwPicDataLen;
                    byte[] by   = new byte[iLen];
                    Marshal.Copy(struAcsAlarmInfo.pPicData, by, 0, iLen);
                    fs.Write(by, 0, iLen);
                    fs.Close();
                }
                szInfoBuf = szInfoBuf + "SavePath:" + path;
            }

            this.listViewAlarmInfo.BeginInvoke(new Action(() =>
            {
                ListViewItem Item = new ListViewItem();
                Item.Text         = (++m_lLogNum).ToString();
                Item.SubItems.Add(DateTime.Now.ToString());
                Item.SubItems.Add(szInfoBuf);
                this.listViewAlarmInfo.Items.Add(Item);
            }));
        }
	void Update ()
    {
        isActive = bossArea.GetComponent<Boss2Area>().playerIsInside;
        if(isActive)
        {
            rend.flipY = false;

            if (this.gameObject.GetComponent<Rigidbody2D>().velocity.x == 0)
            {
                animator.SetBool("FrontFly", true);
                animator.SetBool("LeftFly", false);
                animator.SetBool("RightFly", false);
            }
            else if (this.gameObject.GetComponent<Rigidbody2D>().velocity.x > 0)
            {
                animator.SetBool("FrontFly", false);
                animator.SetBool("LeftFly", false);
                animator.SetBool("RightFly", true);
            }
            else if (this.gameObject.GetComponent<Rigidbody2D>().velocity.x < 0)
            {
                animator.SetBool("FrontFly", false);
                animator.SetBool("LeftFly", true);
                animator.SetBool("RightFly", false);
            }

            if (state == 0)
            {
                float dist = this.GetComponent<Transform>().position.y - state0Position.transform.position.y;
                dist = Mathf.Abs(dist);
                this.gameObject.tag = "Deadly";

                if (dist > 0.01)
                {
                    this.gameObject.GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.None;
                    this.gameObject.GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeRotation;

                    if (randomSpeedDirState0 == 0)
                        randomSpeedDirState0 = Random.Range(50, 150);

                    if (randomSpeedDirState0 > 100)
                        state0SpeedDir = 1;
                    else
                        state0SpeedDir = -1;

                    Vector2 moveToPos = new Vector2(1, state0Position.position.y - this.gameObject.transform.position.y);
                    moveToPos.Normalize();

                    this.gameObject.GetComponent<Rigidbody2D>().velocity = new Vector2(moveToPos.x * state0SpeedDir * 5, moveToPos.y * 5);
                    SFXManager.GetComponent<SFXControllerLevel2>().playBatFly();
                }
                else
                {
                    SFXManager.GetComponent<SFXControllerLevel2>().playBatFly();
                    this.gameObject.GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezePositionY;
                    this.gameObject.GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeRotation;
                    this.gameObject.GetComponent<Rigidbody2D>().velocity = new Vector2(maxSpeed * speedDir, 0);

                    if (health <= 0 && !state0Phase3)
                    {
                        state0Phase3 = true;
                        stalactites3.gameObject.SetActive(false);
                        state = 1;
                    }

                    if (health <= maxHealth * 1 / 3 && !state0Phase2)
                    {
                        state0Phase2 = true;
                        stalactites2.gameObject.SetActive(false);
                        state = 1;
                    }

                    if (health <= maxHealth * 2 / 3 && !state0Phase1)
                    {
                        state0Phase1 = true;
                        stalactites1.gameObject.SetActive(false);
                        state = 1;
                    }
                }

            }
            if (state == 1)
            {
                this.gameObject.GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.None;
                this.gameObject.GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeRotation;

                distanceToSpawn = this.GetComponent<Transform>().position.x - state1position.transform.position.x;
                distanceToSpawn = Mathf.Abs(distanceToSpawn);

                this.gameObject.tag = "Deadly";

                if (distanceToSpawn >= 0.1)
                {
                    SFXManager.GetComponent<SFXControllerLevel2>().playBatFly();
                    rend.flipY = false;
                    Vector2 moveToPos = new Vector2(state1position.position.x - this.gameObject.transform.position.x, state1position.position.y - this.gameObject.transform.position.y);
                    moveToPos.Normalize();

                    this.gameObject.GetComponent<Rigidbody2D>().velocity = moveToPos * 5;
                }
                else
                {
                    rend.flipY = true;
                    animator.SetTrigger("Summon");
                    this.gameObject.GetComponent<Rigidbody2D>().velocity = new Vector2(0, 0);
                    this.gameObject.GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeAll;

                    //Spawn enemies
                    if (state0Phase1 && !state0Phase2 && !state0Phase3)
                        maxEnemies = maxEnemiesCopy;
                    else if (state0Phase1 && state0Phase2 && !state0Phase3)
                        maxEnemies = maxEnemiesCopy * 1.5f;
                    else if (state0Phase1 && state0Phase2 && state0Phase3)
                    {
                        maxEnemies = maxEnemiesCopy * 2f;
                        lastState1 = true;
                    }

                    if (GameObject.Find("Player").GetComponent<Death>().dead)
                    {
                        counter = 0;
                        time = Time.time;
                        spawned = false;
                    }


                    if (counter < maxEnemies && Time.time > time + timeToSpawn)
                    {
                        if (!spawned)
                        {
                            GameObject newEnemy;

                            position = Random.Range(0.0f, distance) + batSpawnLeft.position.x;
                            batSpawn.position = new Vector2(position, batSpawn.transform.position.y);

                            Transform newPosition;
                            newPosition = Instantiate<Transform>(newBat, batSpawn);

                            newEnemy = Instantiate<GameObject>(enemies, newPosition);
                            newEnemy.GetComponent<Transform>().localScale = new Vector3(0.4f, 0.4f, 1);
                            newEnemy.GetComponent<bat>().maxSpeed = Random.Range(1.3f, 2f);
                            enemyCopy = newEnemy;
                            spawned = true;
                        }
                        else
                        {
                            collided = enemyCopy.GetComponent<bat>().collided;
                            if (collided)
                            {
                                counter++;
                                time = Time.time;
                                spawned = false;
                            }
                        }
                    }
                    else if (counter >= maxEnemies)
                    {
                        counter = 0;
                        if (!lastState1)
                        {
                            state = 0;
                            randomSpeedDirState0 = 0;

                            if (state0Phase2)
                                stalactites3.SetActive(true);
                            else if (state0Phase1)
                                stalactites2.SetActive(true);
                        }
                        else
                            state = 2;
                    }
                }

            }
            else if (state == 2)
            {
                this.gameObject.GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.None;
                this.gameObject.GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeRotation;
                animator.SetBool("Knocked", false);
                float distThis = this.GetComponent<Transform>().position.x - state1position.transform.position.x;
                distThis = Mathf.Abs(distThis);
                this.gameObject.tag = "Deadly";

                if (distThis > 0.1)
                {
                    SFXManager.GetComponent<SFXControllerLevel2>().playBatFly();
                    SFXManager.GetComponent<SFXControllerLevel2>().stopBatScream();
                    rend.flipY = false;
                    Vector2 moveToPos = new Vector2(state1position.position.x - this.gameObject.transform.position.x, state1position.position.y - this.gameObject.transform.position.y);
                    moveToPos.Normalize();

                    this.gameObject.GetComponent<Rigidbody2D>().velocity = moveToPos * 5;
                }
                else
                {
                    SFXManager.GetComponent<SFXControllerLevel2>().stopBatFly();
                    SFXManager.GetComponent<SFXControllerLevel2>().playBatScream();
                    rend.flipY = true;
                    animator.SetTrigger("Summon");
                    if (timeForShake == 0)
                        timeForShake = Time.time;

                    else if (timeForShake + timeShaking > Time.time)
                    {
                        this.gameObject.GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeAll;
                        CameraShake.Shake(timeShaking, shakeMag);
                        GameObject.Find("Player").GetComponent<PlayerController>().enabled = false;
                        GameObject.Find("Player").GetComponent<Rigidbody2D>().velocity = new Vector2(0, 0);
                    }
                    else
                    {
                        state = 3;
                        timeForShake = 0;
                        fallTime = Time.time;
                        attackOnceAfterState2 = true;
                        GameObject.Find("Player").GetComponent<PlayerController>().enabled = true;
                    }

                    if (batHit)
                    {
                        batHit = false;
                        this.gameObject.tag = "Enemy";
                        resistance--;
                    }

                }
            }
            else if (state == 3)
            {
                if (fallTime == 0)
                    fallTime = Time.time;

                dist = this.GetComponent<Transform>().position.y - state3Position.transform.position.y;
                dist = Mathf.Abs(dist);

                if (Time.time > fallTime + nextFall)
                    startFall = true;

                this.gameObject.tag = "Deadly";

                if (startFall)
                {
                    moveToPlayer = new Vector2(GameObject.Find("Player").GetComponent<Transform>().position.x - this.GetComponent<Transform>().position.x, GameObject.Find("Player").GetComponent<Transform>().position.y - this.GetComponent<Transform>().position.y);
                    moveToPlayer.Normalize();

                    this.gameObject.GetComponent<Rigidbody2D>().velocity = moveToPlayer * fallSpeed;

                    falling = true;

                    initFallPos = this.GetComponent<Transform>().position.x;

                    distanceToPlayerX = GameObject.Find("Player").GetComponent<Transform>().position.x - this.GetComponent<Transform>().position.x;
                    distanceToPlayerX = Mathf.Abs(distanceToPlayerX);
                    startFall = false;

                    fallTime = 50 * Time.time;
                    falls++;
                }


                if (falling)
                {
                    this.gameObject.GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.None;
                    this.gameObject.GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeRotation;
                    this.gameObject.GetComponent<Rigidbody2D>().velocity = moveToPlayer * fallSpeed;

                    if (groundCol)
                    {
                        if (falls == 4)
                        {
                            this.gameObject.tag = "Enemy";
                            if (Time.time < timeOnGround + timeGround)
                            {
                                animator.SetBool("Knocked", true);
                                this.gameObject.GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeAll;
                            }
                            else
                            {
                                this.gameObject.GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.None;
                                this.gameObject.GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeRotation;
                                falls = 0;
                                falling = false;
                                fallTime = Time.time;
                                nextFall = Random.Range(2f, 3f);
                            }
                        }
                        else
                        {
                            this.gameObject.GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.None;
                            this.gameObject.GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeRotation;
                            falling = false;
                            groundCol = false;
                            fallTime = Time.time;
                            nextFall = Random.Range(2f, 3f);
                        }
                    }
                    else { SFXManager.GetComponent<SFXControllerLevel2>().playBatFly(); }
                }
                else if (dist > 0.01f && !falling)
                {
                    SFXManager.GetComponent<SFXControllerLevel2>().playBatFly();
                    SFXManager.GetComponent<SFXControllerLevel2>().stopBatScream();
                    this.gameObject.GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.None;
                    this.gameObject.GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeRotation;
                    animator.SetBool("Knocked", false);
                    if (initFallPos == 0)
                    {
                        Vector2 moveToPos = new Vector2(state3Position.position.x - this.gameObject.transform.position.x, state3Position.position.y - this.gameObject.transform.position.y);
                        moveToPos.Normalize();

                        this.gameObject.GetComponent<Rigidbody2D>().velocity = moveToPos * 10;
                    }
                    else
                    {
                        Vector2 moveToPos = new Vector2(initFallPos + 2 * speedDir * distanceToPlayerX - this.gameObject.transform.position.x, state3Position.position.y - this.gameObject.transform.position.y);
                        moveToPos.Normalize();

                        this.gameObject.GetComponent<Rigidbody2D>().velocity = moveToPos * 10;
                    }
                }
                else if (dist <= 0.01f && !falling)
                {
                    SFXManager.GetComponent<SFXControllerLevel2>().playBatFly();

                    this.gameObject.GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.None;
                    this.gameObject.GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezePositionY;
                    this.gameObject.GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeRotation;
                    this.gameObject.GetComponent<Rigidbody2D>().velocity = new Vector2(maxSpeed * speedDir, 0);
                }

                if (batHit)
                {
                    state = 2;
                    this.gameObject.tag = "Enemy";
                    SFXManager.GetComponent<SFXControllerLevel2>().stopBatFly();
                    timeForShake = 0;
                }
            }
            else if(state == 4)
            {
                activateCave = true;
                if (!sound)
                {
                    SFXManager.GetComponent<SFXControllerLevel2>().playFall();
                    sound = true;
                }
            }

            if (resistance == 2)
                exitRock.GetComponent<RockBoss>().health = 3;
            else if (resistance == 1)
                exitRock.GetComponent<RockBoss>().health = 2;
            else if (resistance == 0 && !updated)
            {
                exitRock.GetComponent<RockBoss>().health = 1;
                updated = true;
            }

            if (exitRock.GetComponent<RockBoss>().batDie && state != 4)
                state = 4;
        }    
        else
        {
            SFXManager.GetComponent<SFXControllerLevel2>().stopBatFly();
        }
    }
Exemple #39
0
 // Start is called before the first frame update
 void Start()
 {
     speed = Random.Range(5f, 15f);
 }
 // Use this for initialization
 void Start()
 {
     timeStart = Time.time;
     duration = Random.Range(duration - durationVariance, duration + durationVariance);
     // ^ Set the duration to a number between 3.5 and 4.5 (defaults)
 }
        private static Network InitStratisMain()
        {
            Block.BlockSignature = true;
            Transaction.TimeStamp = true;

            var consensus = new Consensus();

            consensus.NetworkOptions = new NetworkOptions() { IsProofOfStake = true };
            consensus.GetPoWHash = (n, h) => Crypto.HashX13.Instance.Hash(h.ToBytes(options:n)); 

            consensus.SubsidyHalvingInterval = 210000;
            consensus.MajorityEnforceBlockUpgrade = 750;
            consensus.MajorityRejectBlockOutdated = 950;
            consensus.MajorityWindow = 1000;
            consensus.BuriedDeployments[BuriedDeployments.BIP34] = 227931;
            consensus.BuriedDeployments[BuriedDeployments.BIP65] = 388381;
            consensus.BuriedDeployments[BuriedDeployments.BIP66] = 363725;
            consensus.BIP34Hash = new uint256("0x000000000000024b89b42a942fe0d9fea3bb44ab7bd1b19115dd6a759c0808b8");
            consensus.PowLimit = new Target(new uint256("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"));
            consensus.PowTargetTimespan = TimeSpan.FromSeconds(14 * 24 * 60 * 60); // two weeks
            consensus.PowTargetSpacing = TimeSpan.FromSeconds(10 * 60);
            consensus.PowAllowMinDifficultyBlocks = false;
            consensus.PowNoRetargeting = false;
            consensus.RuleChangeActivationThreshold = 1916; // 95% of 2016
            consensus.MinerConfirmationWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing

            consensus.BIP9Deployments[BIP9Deployments.TestDummy] = new BIP9DeploymentsParameters(28, 1199145601, 1230767999);
            consensus.BIP9Deployments[BIP9Deployments.CSV] = new BIP9DeploymentsParameters(0, 1462060800, 1493596800);
            consensus.BIP9Deployments[BIP9Deployments.Segwit] = new BIP9DeploymentsParameters(1, 0, 0);

            consensus.LastPOWBlock = 12500;

            consensus.ProofOfStakeLimit =   new BigInteger(uint256.Parse("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").ToBytes(false));
            consensus.ProofOfStakeLimitV2 = new BigInteger(uint256.Parse("000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffff").ToBytes(false));

            consensus.CoinType = 105;

            consensus.DefaultAssumeValid = new uint256("0x8c2cf95f9ca72e13c8c4cdf15c2d7cc49993946fb49be4be147e106d502f1869"); // 642930

            Block genesis = CreateStratisGenesisBlock(1470467000, 1831645, 0x1e0fffff, 1, Money.Zero);
            consensus.HashGenesisBlock = genesis.GetHash(consensus.NetworkOptions);

            // The message start string is designed to be unlikely to occur in normal data.
            // The characters are rarely used upper ASCII, not valid as UTF-8, and produce
            // a large 4-byte int at any alignment.
            var messageStart = new byte[4];
            messageStart[0] = 0x70;
            messageStart[1] = 0x35;
            messageStart[2] = 0x22;
            messageStart[3] = 0x05;
            var magic = BitConverter.ToUInt32(messageStart, 0); //0x5223570; 

            Assert(consensus.HashGenesisBlock == uint256.Parse("0x0000066e91e46e5a264d42c89e1204963b2ee6be230b443e9159020539d972af"));
            Assert(genesis.Header.HashMerkleRoot == uint256.Parse("0x65a26bc20b0351aebf05829daefa8f7db2f800623439f3c114257c91447f1518"));

            var builder = new NetworkBuilder()
                .SetName("StratisMain")
                .SetConsensus(consensus)
                .SetMagic(magic)
                .SetGenesis(genesis)
                .SetPort(16178)
                .SetRPCPort(16174)
                .SetTxFees(10000, 60000, 10000)

                .AddDNSSeeds(new[]
                {
                    new DNSSeedData("seednode1.stratisplatform.com", "seednode1.stratisplatform.com"),
                    new DNSSeedData("seednode2.stratis.cloud", "seednode2.stratis.cloud"),
                    new DNSSeedData("seednode3.stratisplatform.com", "seednode3.stratisplatform.com"),
                    new DNSSeedData("seednode4.stratis.cloud", "seednode4.stratis.cloud")
                })

                .SetBase58Bytes(Base58Type.PUBKEY_ADDRESS, new byte[] {(63)})
                .SetBase58Bytes(Base58Type.SCRIPT_ADDRESS, new byte[] {(125)})
                .SetBase58Bytes(Base58Type.SECRET_KEY, new byte[] {(63 + 128)})
                .SetBase58Bytes(Base58Type.ENCRYPTED_SECRET_KEY_NO_EC, new byte[] {0x01, 0x42})
                .SetBase58Bytes(Base58Type.ENCRYPTED_SECRET_KEY_EC, new byte[] {0x01, 0x43})
                .SetBase58Bytes(Base58Type.EXT_PUBLIC_KEY, new byte[] {(0x04), (0x88), (0xB2), (0x1E)})
                .SetBase58Bytes(Base58Type.EXT_SECRET_KEY, new byte[] {(0x04), (0x88), (0xAD), (0xE4)})
                .SetBase58Bytes(Base58Type.PASSPHRASE_CODE, new byte[] {0x2C, 0xE9, 0xB3, 0xE1, 0xFF, 0x39, 0xE2})
                .SetBase58Bytes(Base58Type.CONFIRMATION_CODE, new byte[] {0x64, 0x3B, 0xF6, 0xA8, 0x9A})
                .SetBase58Bytes(Base58Type.STEALTH_ADDRESS, new byte[] {0x2a})
                .SetBase58Bytes(Base58Type.ASSET_ID, new byte[] {23})
                .SetBase58Bytes(Base58Type.COLORED_ADDRESS, new byte[] {0x13})
                .SetBech32(Bech32Type.WITNESS_PUBKEY_ADDRESS, "bc")
                .SetBech32(Bech32Type.WITNESS_SCRIPT_ADDRESS, "bc");

            var seed = new[] { "101.200.198.155", "103.24.76.21", "104.172.24.79" };
            var fixedSeeds = new List<NetworkAddress>();
            // Convert the pnSeeds array into usable address objects.
            Random rand = new Random();
            TimeSpan oneWeek = TimeSpan.FromDays(7);
            for (int i = 0; i < seed.Length; i++)
            {
                // It'll only connect to one or two seed nodes because once it connects,
                // it'll get a pile of addresses with newer timestamps.                
                NetworkAddress addr = new NetworkAddress();
                // Seed nodes are given a random 'last seen time' of between one and two
                // weeks ago.
                addr.Time = DateTime.UtcNow - (TimeSpan.FromSeconds(rand.NextDouble() * oneWeek.TotalSeconds)) - oneWeek;
                addr.Endpoint = Utils.ParseIpEndpoint(seed[i], builder.Port);
                fixedSeeds.Add(addr);
            }

            builder.AddSeeds(fixedSeeds);
            return builder.BuildAndRegister();
        }
	// Update is called once per frame
	void Update () {
        spawnWait = Random.Range(spawnLessWait, spawnMostWait);
	}
Exemple #43
0
	void Awake () {
        SP = this;
        
        spawnInterval = Random.Range(3.5f, 5.5f);
        lastSpawnTime = Time.time + Random.Range(0.0f, 1.5f);
	}
        private static Network InitMain()
        {
            Network network = new Network();

            network.Name = "Main";

            Consensus consensus = network.consensus;

            consensus.SubsidyHalvingInterval = 210000;
            consensus.MajorityEnforceBlockUpgrade = 750;
            consensus.MajorityRejectBlockOutdated = 950;
            consensus.MajorityWindow = 1000;
            consensus.BuriedDeployments[BuriedDeployments.BIP34] = 227931;
            consensus.BuriedDeployments[BuriedDeployments.BIP65] = 388381;
            consensus.BuriedDeployments[BuriedDeployments.BIP66] = 363725;
            consensus.BIP34Hash = new uint256("0x000000000000024b89b42a942fe0d9fea3bb44ab7bd1b19115dd6a759c0808b8");
            consensus.PowLimit = new Target(new uint256("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff"));
            consensus.MinimumChainWork = new uint256("0x0000000000000000000000000000000000000000002cb971dd56d1c583c20f90");
            consensus.PowTargetTimespan = TimeSpan.FromSeconds(14 * 24 * 60 * 60); // two weeks
            consensus.PowTargetSpacing = TimeSpan.FromSeconds(10 * 60);
            consensus.PowAllowMinDifficultyBlocks = false;
            consensus.PowNoRetargeting = false;
            consensus.RuleChangeActivationThreshold = 1916; // 95% of 2016
            consensus.MinerConfirmationWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing

            consensus.BIP9Deployments[BIP9Deployments.TestDummy] = new BIP9DeploymentsParameters(28, 1199145601, 1230767999);
            consensus.BIP9Deployments[BIP9Deployments.CSV] = new BIP9DeploymentsParameters(0, 1462060800, 1493596800);
            consensus.BIP9Deployments[BIP9Deployments.Segwit] = new BIP9DeploymentsParameters(1, 1479168000, 1510704000);

            consensus.CoinType = 0;

            consensus.DefaultAssumeValid = new uint256("0x00000000000000000086a2362d78ffb4e41dc0b8775ff3c278bd994a5162348a"); // 499610

            // The message start string is designed to be unlikely to occur in normal data.
            // The characters are rarely used upper ASCII, not valid as UTF-8, and produce
            // a large 4-byte int at any alignment.
            network.magic = 0xD9B4BEF9;
            network.alertPubKeyArray = Encoders.Hex.DecodeData("04fc9702847840aaf195de8442ebecedf5b095cdbb9bc716bda9110971b28a49e0ead8564ff0db22209e0374782c093bb899692d524e9d6a6956e7c5ecbcd68284");
            network.DefaultPort = 8333;
            network.RPCPort = 8332;

            network.genesis = CreateGenesisBlock(1231006505, 2083236893, 0x1d00ffff, 1, Money.Coins(50m));
            consensus.HashGenesisBlock = network.genesis.GetHash();
            Assert(consensus.HashGenesisBlock == uint256.Parse("0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"));
            Assert(network.genesis.Header.HashMerkleRoot == uint256.Parse("0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"));
            network.seeds.Add(new DNSSeedData("bitcoin.sipa.be", "seed.bitcoin.sipa.be")); // Pieter Wuille
            network.seeds.Add(new DNSSeedData("bluematt.me", "dnsseed.bluematt.me")); // Matt Corallo
            network.seeds.Add(new DNSSeedData("dashjr.org", "dnsseed.bitcoin.dashjr.org")); // Luke Dashjr
            network.seeds.Add(new DNSSeedData("bitcoinstats.com", "seed.bitcoinstats.com")); // Christian Decker
            network.seeds.Add(new DNSSeedData("xf2.org", "bitseed.xf2.org")); // Jeff Garzik
            network.seeds.Add(new DNSSeedData("bitcoin.jonasschnelli.ch", "seed.bitcoin.jonasschnelli.ch")); // Jonas Schnelli
            network.base58Prefixes[(int)Base58Type.PUBKEY_ADDRESS] = new byte[] { (0) };
            network.base58Prefixes[(int)Base58Type.SCRIPT_ADDRESS] = new byte[] { (5) };
            network.base58Prefixes[(int)Base58Type.SECRET_KEY] = new byte[] { (128) };
            network.base58Prefixes[(int)Base58Type.ENCRYPTED_SECRET_KEY_NO_EC] = new byte[] { 0x01, 0x42 };
            network.base58Prefixes[(int)Base58Type.ENCRYPTED_SECRET_KEY_EC] = new byte[] { 0x01, 0x43 };
            network.base58Prefixes[(int)Base58Type.EXT_PUBLIC_KEY] = new byte[] { (0x04), (0x88), (0xB2), (0x1E) };
            network.base58Prefixes[(int)Base58Type.EXT_SECRET_KEY] = new byte[] { (0x04), (0x88), (0xAD), (0xE4) };
            network.base58Prefixes[(int)Base58Type.PASSPHRASE_CODE] = new byte[] { 0x2C, 0xE9, 0xB3, 0xE1, 0xFF, 0x39, 0xE2 };
            network.base58Prefixes[(int)Base58Type.CONFIRMATION_CODE] = new byte[] { 0x64, 0x3B, 0xF6, 0xA8, 0x9A };
            network.base58Prefixes[(int)Base58Type.STEALTH_ADDRESS] = new byte[] { 0x2a };
            network.base58Prefixes[(int)Base58Type.ASSET_ID] = new byte[] { 23 };
            network.base58Prefixes[(int)Base58Type.COLORED_ADDRESS] = new byte[] { 0x13 };

            var encoder = new Bech32Encoder("bc");
            network.bech32Encoders[(int)Bech32Type.WITNESS_PUBKEY_ADDRESS] = encoder;
            network.bech32Encoders[(int)Bech32Type.WITNESS_SCRIPT_ADDRESS] = encoder;

            // Convert the pnSeeds array into usable address objects.
            string[] pnSeed = new[] { "1.34.168.128:8333", "1.202.128.218:8333", "2.30.0.210:8333", "5.9.96.203:8333", "5.45.71.130:8333", "5.45.98.141:8333", "5.102.145.68:8333", "5.135.160.77:8333", "5.189.134.246:8333", "5.199.164.132:8333", "5.249.135.102:8333", "8.19.44.110:8333", "8.22.230.8:8333", "14.200.200.145:8333", "18.228.0.188:8333", "18.228.0.200:8333", "23.24.168.97:8333", "23.28.35.227:8333", "23.92.76.170:8333", "23.99.64.119:8333", "23.228.166.128:8333", "23.229.45.32:8333", "24.8.105.128:8333", "24.16.69.137:8333", "24.94.98.96:8333", "24.102.118.7:8333", "24.118.166.228:8333", "24.122.133.49:8333", "24.166.97.162:8333", "24.213.235.242:8333", "24.226.107.64:8333", "24.228.192.171:8333", "27.140.133.18:8333", "31.41.40.25:8333", "31.43.101.59:8333", "31.184.195.181:8333", "31.193.139.66:8333", "37.200.70.102:8333", "37.205.10.151:8333", "42.3.106.227:8333", "42.60.133.106:8333", "45.56.85.231:8333", "45.56.102.228:8333", "45.79.130.235:8333", "46.28.204.61:11101", "46.38.235.229:8333", "46.59.2.74:8333", "46.101.132.37:8333", "46.101.168.50:8333", "46.163.76.230:8333", "46.166.161.103:8333", "46.182.132.100:8333", "46.223.36.94:8333", "46.227.66.132:8333", "46.227.66.138:8333", "46.239.107.74:8333", "46.249.39.100:8333", "46.250.98.108:8333", "50.7.37.114:8333", "50.81.53.151:8333", "50.115.43.253:8333", "50.116.20.87:8333", "50.116.33.92:8333", "50.125.167.245:8333", "50.143.9.51:8333", "50.188.192.133:8333", "54.77.162.76:8333", "54.153.97.109:8333", "54.165.192.125:8333", "58.96.105.85:8333", "59.167.196.135:8333", "60.29.227.163:8333", "61.35.225.19:8333", "62.43.130.178:8333", "62.109.49.26:8333", "62.202.0.97:8333", "62.210.66.227:8333", "62.210.192.169:8333", "64.74.98.205:8333", "64.156.193.100:8333", "64.203.102.86:8333", "64.229.142.48:8333", "65.96.193.165:8333", "66.30.3.7:8333", "66.114.33.49:8333", "66.118.133.194:8333", "66.135.10.126:8333", "66.172.10.4:8333", "66.194.38.250:8333", "66.194.38.253:8333", "66.215.192.104:8333", "67.60.98.115:8333", "67.164.35.36:8333", "67.191.162.244:8333", "67.207.195.77:8333", "67.219.233.140:8333", "67.221.193.55:8333", "67.228.162.228:8333", "68.50.67.199:8333", "68.62.3.203:8333", "68.65.205.226:9000", "68.106.42.191:8333", "68.150.181.198:8333", "68.196.196.106:8333", "68.224.194.81:8333", "69.46.5.194:8333", "69.50.171.238:8333", "69.64.43.152:8333", "69.65.41.13:8333", "69.90.132.200:8333", "69.143.1.243:8333", "69.146.98.216:8333", "69.165.246.38:8333", "69.207.6.135:8333", "69.251.208.26:8333", "70.38.1.101:8333", "70.38.9.66:8333", "70.90.2.18:8333", "71.58.228.226:8333", "71.199.11.189:8333", "71.199.193.202:8333", "71.205.232.181:8333", "71.236.200.162:8333", "72.24.73.186:8333", "72.52.130.110:8333", "72.53.111.37:8333", "72.235.38.70:8333", "73.31.171.149:8333", "73.32.137.72:8333", "73.137.133.238:8333", "73.181.192.103:8333", "73.190.2.60:8333", "73.195.192.137:8333", "73.222.35.117:8333", "74.57.199.180:8333", "74.82.233.205:8333", "74.85.66.82:8333", "74.101.224.127:8333", "74.113.69.16:8333", "74.122.235.68:8333", "74.193.68.141:8333", "74.208.164.219:8333", "75.100.37.122:8333", "75.145.149.169:8333", "75.168.34.20:8333", "76.20.44.240:8333", "76.100.70.17:8333", "76.168.3.239:8333", "76.186.140.103:8333", "77.92.68.221:8333", "77.109.101.142:8333", "77.110.11.86:8333", "77.242.108.18:8333", "78.46.96.150:9020", "78.84.100.95:8333", "79.132.230.144:8333", "79.133.43.63:8333", "79.160.76.153:8333", "79.169.34.24:8333", "79.188.7.78:8333", "80.217.226.25:8333", "80.223.100.179:8333", "80.240.129.221:8333", "81.1.173.243:8333", "81.7.11.50:8333", "81.7.16.17:8333", "81.66.111.3:8333", "81.80.9.71:8333", "81.140.43.138:8333", "81.171.34.37:8333", "81.174.247.50:8333", "81.181.155.53:8333", "81.184.5.253:8333", "81.187.69.130:8333", "81.230.3.84:8333", "82.42.128.51:8333", "82.74.226.21:8333", "82.142.75.50:8333", "82.199.102.10:8333", "82.200.205.30:8333", "82.221.108.21:8333", "82.221.128.35:8333", "82.238.124.41:8333", "82.242.0.245:8333", "83.76.123.110:8333", "83.150.9.196:8333", "83.162.196.192:8333", "83.162.234.224:8333", "83.170.104.91:8333", "83.255.66.118:8334", "84.2.34.104:8333", "84.45.98.91:8333", "84.47.161.150:8333", "84.212.192.131:8333", "84.215.169.101:8333", "84.238.140.176:8333", "84.245.71.31:8333", "85.17.4.212:8333", "85.114.128.134:8333", "85.159.237.191:8333", "85.166.130.189:8333", "85.199.4.228:8333", "85.214.66.168:8333", "85.214.195.210:8333", "85.229.0.73:8333", "86.21.96.45:8333", "87.48.42.199:8333", "87.81.143.82:8333", "87.81.251.72:8333", "87.104.24.185:8333", "87.104.168.104:8333", "87.117.234.71:8333", "87.118.96.197:8333", "87.145.12.57:8333", "87.159.170.190:8333", "88.150.168.160:8333", "88.208.0.79:8333", "88.208.0.149:8333", "88.214.194.226:8343", "89.1.11.32:8333", "89.36.235.108:8333", "89.67.96.2:15321", "89.98.16.41:8333", "89.108.72.195:8333", "89.156.35.157:8333", "89.163.227.28:8333", "89.212.33.237:8333", "89.212.160.165:8333", "89.231.96.83:8333", "89.248.164.64:8333", "90.149.193.199:8333", "91.77.239.245:8333", "91.106.194.97:8333", "91.126.77.77:8333", "91.134.38.195:8333", "91.156.97.181:8333", "91.207.68.144:8333", "91.209.77.101:8333", "91.214.200.205:8333", "91.220.131.242:8333", "91.220.163.18:8333", "91.233.23.35:8333", "92.13.96.93:8333", "92.14.74.114:8333", "92.27.7.209:8333", "92.221.228.13:8333", "92.255.207.73:8333", "93.72.167.148:8333", "93.74.163.234:8333", "93.123.174.66:8333", "93.152.166.29:8333", "93.181.45.188:8333", "94.19.12.244:8333", "94.190.227.112:8333", "94.198.135.29:8333", "94.224.162.65:8333", "94.226.107.86:8333", "94.242.198.161:8333", "95.31.10.209:8333", "95.65.72.244:8333", "95.84.162.95:8333", "95.90.139.46:8333", "95.183.49.27:8005", "95.215.47.133:8333", "96.23.67.85:8333", "96.44.166.190:8333", "97.93.225.74:8333", "98.26.0.34:8333", "98.27.225.102:8333", "98.229.117.229:8333", "98.249.68.125:8333", "98.255.5.155:8333", "99.101.240.114:8333", "101.100.174.138:8333", "101.251.203.6:8333", "103.3.60.61:8333", "103.30.42.189:8333", "103.224.165.48:8333", "104.36.83.233:8333", "104.37.129.22:8333", "104.54.192.251:8333", "104.128.228.252:8333", "104.128.230.185:8334", "104.130.161.47:8333", "104.131.33.60:8333", "104.143.0.156:8333", "104.156.111.72:8333", "104.167.111.84:8333", "104.193.40.248:8333", "104.197.7.174:8333", "104.197.8.250:8333", "104.223.1.133:8333", "104.236.97.140:8333", "104.238.128.214:8333", "104.238.130.182:8333", "106.38.234.84:8333", "106.185.36.204:8333", "107.6.4.145:8333", "107.150.2.6:8333", "107.150.40.234:8333", "107.155.108.130:8333", "107.161.182.115:8333", "107.170.66.231:8333", "107.190.128.226:8333", "107.191.106.115:8333", "108.16.2.61:8333", "109.70.4.168:8333", "109.162.35.196:8333", "109.163.235.239:8333", "109.190.196.220:8333", "109.191.39.60:8333", "109.234.106.191:8333", "109.238.81.82:8333", "114.76.147.27:8333", "115.28.224.127:8333", "115.68.110.82:18333", "118.97.79.218:8333", "118.189.207.197:8333", "119.228.96.233:8333", "120.147.178.81:8333", "121.41.123.5:8333", "121.67.5.230:8333", "122.107.143.110:8333", "123.2.170.98:8333", "123.110.65.94:8333", "123.193.139.19:8333", "125.239.160.41:8333", "128.101.162.193:8333", "128.111.73.10:8333", "128.140.229.73:8333", "128.175.195.31:8333", "128.199.107.63:8333", "128.199.192.153:8333", "128.253.3.193:20020", "129.123.7.7:8333", "130.89.160.234:8333", "131.72.139.164:8333", "131.191.112.98:8333", "133.1.134.162:8333", "134.19.132.53:8333", "137.226.34.42:8333", "141.41.2.172:8333", "141.255.128.204:8333", "142.217.12.106:8333", "143.215.129.126:8333", "146.0.32.101:8337", "147.229.13.199:8333", "149.210.133.244:8333", "149.210.162.187:8333", "150.101.163.241:8333", "151.236.11.189:8333", "153.121.66.211:8333", "154.20.2.139:8333", "159.253.23.132:8333", "162.209.106.123:8333", "162.210.198.184:8333", "162.218.65.121:8333", "162.222.161.49:8333", "162.243.132.6:8333", "162.243.132.58:8333", "162.248.99.164:53011", "162.248.102.117:8333", "163.158.35.110:8333", "164.15.10.189:8333", "164.40.134.171:8333", "166.230.71.67:8333", "167.160.161.199:8333", "168.103.195.250:8333", "168.144.27.112:8333", "168.158.129.29:8333", "170.75.162.86:8333", "172.90.99.174:8333", "172.245.5.156:8333", "173.23.166.47:8333", "173.32.11.194:8333", "173.34.203.76:8333", "173.171.1.52:8333", "173.175.136.13:8333", "173.230.228.139:8333", "173.247.193.70:8333", "174.49.132.28:8333", "174.52.202.72:8333", "174.53.76.87:8333", "174.109.33.28:8333", "176.28.12.169:8333", "176.35.182.214:8333", "176.36.33.113:8333", "176.36.33.121:8333", "176.58.96.173:8333", "176.121.76.84:8333", "178.62.70.16:8333", "178.62.111.26:8333", "178.76.169.59:8333", "178.79.131.32:8333", "178.162.199.216:8333", "178.175.134.35:8333", "178.248.111.4:8333", "178.254.1.170:8333", "178.254.34.161:8333", "179.43.143.120:8333", "179.208.156.198:8333", "180.200.128.58:8333", "183.78.169.108:8333", "183.96.96.152:8333", "184.68.2.46:8333", "184.73.160.160:8333", "184.94.227.58:8333", "184.152.68.163:8333", "185.7.35.114:8333", "185.28.76.179:8333", "185.31.160.202:8333", "185.45.192.129:8333", "185.66.140.15:8333", "186.2.167.23:8333", "186.220.101.142:8333", "188.26.5.33:8333", "188.75.136.146:8333", "188.120.194.140:8333", "188.121.5.150:8333", "188.138.0.114:8333", "188.138.33.239:8333", "188.166.0.82:8333", "188.182.108.129:8333", "188.191.97.208:8333", "188.226.198.102:8001", "190.10.9.217:8333", "190.75.143.144:8333", "190.139.102.146:8333", "191.237.64.28:8333", "192.3.131.61:8333", "192.99.225.3:8333", "192.110.160.122:8333", "192.146.137.1:8333", "192.183.198.204:8333", "192.203.228.71:8333", "193.0.109.3:8333", "193.12.238.204:8333", "193.91.200.85:8333", "193.234.225.156:8333", "194.6.233.38:8333", "194.63.143.136:8333", "194.126.100.246:8333", "195.134.99.195:8333", "195.159.111.98:8333", "195.159.226.139:8333", "195.197.175.190:8333", "198.48.199.108:8333", "198.57.208.134:8333", "198.57.210.27:8333", "198.62.109.223:8333", "198.167.140.8:8333", "198.167.140.18:8333", "199.91.173.234:8333", "199.127.226.245:8333", "199.180.134.116:8333", "200.7.96.99:8333", "201.160.106.86:8333", "202.55.87.45:8333", "202.60.68.242:8333", "202.60.69.232:8333", "202.124.109.103:8333", "203.30.197.77:8333", "203.88.160.43:8333", "203.151.140.14:8333", "203.219.14.204:8333", "205.147.40.62:8333", "207.235.39.214:8333", "207.244.73.8:8333", "208.12.64.225:8333", "208.76.200.200:8333", "209.40.96.121:8333", "209.126.107.176:8333", "209.141.40.149:8333", "209.190.75.59:8333", "209.208.111.142:8333", "210.54.34.164:8333", "211.72.66.229:8333", "212.51.144.42:8333", "212.112.33.157:8333", "212.116.72.63:8333", "212.126.14.122:8333", "213.66.205.194:8333", "213.111.196.21:8333", "213.122.107.102:8333", "213.136.75.175:8333", "213.155.7.24:8333", "213.163.64.31:8333", "213.163.64.208:8333", "213.165.86.136:8333", "213.184.8.22:8333", "216.15.78.182:8333", "216.55.143.154:8333", "216.115.235.32:8333", "216.126.226.166:8333", "216.145.67.87:8333", "216.169.141.169:8333", "216.249.92.230:8333", "216.250.138.230:8333", "217.20.171.43:8333", "217.23.2.71:8333", "217.23.2.242:8333", "217.25.9.76:8333", "217.40.226.169:8333", "217.123.98.9:8333", "217.155.36.62:8333", "217.172.32.18:20993", "218.61.196.202:8333", "218.231.205.41:8333", "220.233.77.200:8333", "223.18.226.85:8333", "223.197.203.82:8333", "223.255.166.142:8333" };

            Random rand = new Random();
            TimeSpan nOneWeek = TimeSpan.FromDays(7);
            for (int i = 0; i < pnSeed.Length; i++)
            {
                // It'll only connect to one or two seed nodes because once it connects,
                // it'll get a pile of addresses with newer timestamps.                
                NetworkAddress addr = new NetworkAddress();
                // Seed nodes are given a random 'last seen time' of between one and two
                // weeks ago.
                addr.Time = DateTime.UtcNow - (TimeSpan.FromSeconds(rand.NextDouble() * nOneWeek.TotalSeconds)) - nOneWeek;
                addr.Endpoint = Utils.ParseIpEndpoint(pnSeed[i], network.DefaultPort);
                network.fixedSeeds.Add(addr);
            }
            network.MinTxFee = 1000;
            network.FallbackFee = 20000;
            network.MinRelayTxFee = 1000;

            NetworksContainer.TryAdd("mainnet", network);
            NetworksContainer.TryAdd(network.Name.ToLowerInvariant(), network);

            return network;
        }
Exemple #45
0
    /// <summary>
    /// Creates the block.
    /// </summary>
    private void launchBlock()
    {
        blockArray[blockArrayPointer].GetComponent <BlockController> ().setOffset();
        blockArray[blockArrayPointer].GetComponent <Barricade>().launch();
        blockArray[blockArrayPointer].GetComponent <SpriteRenderer> ().sprite = blockSprites [Random.Range(0, blockSprites.Length)];

        blockArrayPointer++;
        blockArrayPointer = blockArrayPointer % 10;
    }
Exemple #46
0
        public static BitmapPalette Clusterise(BitmapPalette palette, byte[] image, int iterations)
        {
            Random rand = new Random();
            double rate = 0.3;

            double[][] positions = new double[palette.Colors.Count][];
            for (int i = 0; i < palette.Colors.Count; i++)
            {
                positions[i] = new double[3];
            }
            double[,] means = new double[palette.Colors.Count, 3];
            int[] pointCounts = new int[palette.Colors.Count];
            for (int i = 0; i < pointCounts.Length; i++)
            {
                positions[i][0] = palette.Colors[i].R;
                positions[i][1] = palette.Colors[i].G;
                positions[i][2] = palette.Colors[i].B;
            }
            for (int iter = 0; iter < iterations; iter++)
            {
                for (int i = 0; i < image.Length; i += 4)
                {
                    double min   = 0;
                    bool   first = true;
                    int    minid = 0;
                    double r     = image[i + 2];
                    double g     = image[i + 1];
                    double b     = image[i + 0];
                    if (image[i + 3] > 128)
                    {
                        for (int c = 0; c < pointCounts.Length; c++)
                        {
                            double _r      = r - positions[c][0];
                            double _g      = g - positions[c][1];
                            double _b      = b - positions[c][2];
                            double distsqr = _r * _r + _g * _g + _b * _b;
                            if (distsqr < min || first)
                            {
                                min   = distsqr;
                                first = false;
                                minid = c;
                            }
                        }
                    }
                    int count = pointCounts[minid];
                    means[minid, 0] = (means[minid, 0] * count + r) / (count + 1);
                    means[minid, 1] = (means[minid, 1] * count + g) / (count + 1);
                    means[minid, 2] = (means[minid, 2] * count + b) / (count + 1);
                    pointCounts[minid]++;
                }
                for (int i = 0; i < pointCounts.Length; i++)
                {
                    for (int c = 0; c < 3; c++)
                    {
                        positions[i][c] = positions[i][c] * (1 - rate) + means[i, c] * rate;
                    }
                }
                for (int i = 0; i < pointCounts.Length; i++)
                {
                    if (pointCounts[i] == 0)
                    {
                        int p = rand.Next(image.Length / 4);
                        positions[i][0] = image[p * 4 + 2];
                        positions[i][1] = image[p * 4 + 1];
                        positions[i][2] = image[p * 4 + 0];
                    }
                }
            }
            var newcol = new List <Color>();

            Array.Sort(pointCounts, positions);
            Array.Reverse(positions);
            for (int i = 0; i < pointCounts.Length; i++)
            {
                newcol.Add(Color.FromRgb((byte)positions[i][0], (byte)positions[i][1], (byte)positions[i][2]));
            }
            return(new BitmapPalette(newcol));
        }
    private void FixedUpdate()
    {
        if (!pView.IsMine)
        {
            return;
        }

        if (gameStarted)
        {
            if (!dead)
            {
                //Once the Player is grounded
                if (controller.isGrounded)
                {
                    if (navAgent.isActiveAndEnabled)
                    {
                        if (navAgent.isOnNavMesh)
                        {

                            targetPosition = aif.getTarget();
                            if (!targetPosition.AlmostEquals(navAgent.destination, 15f)
                                && !navAgent.pathPending
                                && Vector3.Distance(transform.position, targetPosition) > 10f)
                            {
                                findNewTarget();
                            }
                            else if (navAgent.pathPending && !transform.position.AlmostEquals(navAgent.destination, 15f))
                            {
                                pathPending = true;
                                if (aiNumber == 4)
                                {
                                    Debug.Log("Manually moving " + playerName);
                                }
                                movePlayerForward();

                            }
                            else
                            {
                                pathPending = false;
                                if (aiNumber == 4)
                                {
                                    Debug.Log("Auto move enabled " + playerName);
                                }
                            }
                            //turns towards the player it's attacking
                            if (isTargetPlayer && navAgent.remainingDistance < 15f)
                            {
                                if (aiNumber == 4)
                                {
                                    Debug.Log("Rotating Playa " + playerName);
                                }
                                movementVector = (targetPosition - transform.position).normalized;
                                rotateToTarget(5f);
                            }
                        }
                        else
                        {
                            if (aiNumber == 4)
                            {
                                Debug.Log("jumping because I'm off the navmesh -" + playerName);
                            }
                            //Debug.Log(playerName + " jumping because I'm off the navmesh");
                            jumpForwards(15f);
                        }
                    }
                    else
                    {
                        //Debug.Log("Enabling Nav Agent " + playerName);
                        navAgent.enabled = true;
                        if (navAgent.isOnNavMesh 
                            && !navAgent.pathPending 
                            && !targetPosition.AlmostEquals(navAgent.destination, 15f))
                        {

                            //Debug.Log("setting dest on " + playerName);
                            findNewTarget();
                           // if (!targetPosition.AlmostEquals(navAgent.destination, 5f))
                          //  {
                          //      navAgent.SetDestination(targetPosition);
                                //Debug.Log(playerName + " moving to " + navAgent.destination.ToString() + " from " + targetPosition.ToString());
                           // }
                          //  else
                          //  {
                                //Debug.Log(playerName + " is basically at my destination " + navAgent.destination.ToString() + " from " + targetPosition.ToString());
                         //   }
                            /* }*/
                        }
                        /*Debug.Log(playerName + " is grounded apparently with navagent off");
                        navAgent.enabled = true;
                        jumping = false;
                        targetPosition = aif.getTarget();
                        if (navAgent.isOnNavMesh)
                        {
                            if (!targetPosition.AlmostEquals(navAgent.destination, 5f))
                            {
                                navAgent.SetDestination(targetPosition);
                            }
                        }*/
                    }

                    if (jumping)
                    {
                        if (aiNumber == 4)
                        {
                            Debug.Log("landed! -" + playerName);
                        }
                        //next jump randomly between .6 and 1 so they're not jumping in unison
                        // nextPosCheck += Random.Range(.6f, 3.5f);//was 1.2
                        // moveDirection = Vector3.zero;
                        //Debug.Log(playerName + " finished jump");
                        navAgent.enabled = true;
                        jumping = false;

                        if (isTargetPlayer)
                        {
                            nextPosCheck += Random.Range(.05f, 2f);
                        }
                        else
                        {
                            nextPosCheck += Random.Range(.5f, 5f);
                        }
                        if (navAgent.isActiveAndEnabled)
                        {
                            //distance = navAgent.remainingDistance;
                            if (navAgent.isOnNavMesh)
                            {
                                if (!targetPosition.AlmostEquals(navAgent.destination, 5f) && !navAgent.pathPending)
                                //if (!targetPosition.AlmostEquals(navAgent.destination, 5f))
                                {
                                    //Debug.Log("Resetting position post jump for " + playerName);
                                    findNewTarget();
                                }
                                /* }*/
                            }
                        }
                            // targetPosition = aif.getTarget();
                            /*if (navAgent.isOnNavMesh)
                            {
                                if (!targetPosition.AlmostEquals(navAgent.destination, 5f))
                               // if (!transform.position.AlmostEquals(navAgent.destination, 5f))
                                {*/
                            //if (navAgent.isOnNavMesh)
                            //{
                            //    navAgent.SetDestination(targetPosition);
                            //}
                            /*}
                        }*/

                        }
                    //This code was going to be used to see if facing correctly

                    //if(isShooting){
                    //    float angle = Vector3.Angle(transform.position, target.transform.position);
                    //    //Debug.Log("Angle: " + angle);
                    //    if(angle > -20f && angle < 20f) {
                    //        angleClose = true;
                    //    }
                    //    else{
                    //        angleClose = false;
                    //    }

                    //}

                    ac.SetBool("jumping", false);

                    if (!(navAgent.velocity.magnitude > 0f) && !pathPending)
                    {
                        ac.SetBool("running", false);
                    }
                    else
                    {
                        ac.SetBool("running", true);
                    }
                    if (navAgent.isOnNavMesh)
                    {
                        if (navAgent.remainingDistance > 10f)
                        {
                            //nextRun = Time.time + runTime;
                            sprinting = true;
                            navAgent.speed = 17f;
                        }
                        else
                        {
                            sprinting = false;
                            navAgent.speed = 11f;
                        }
                    }

                    //int randJump = Random.Range(0, 1000);
                    //if(skillLevel * 10f > randJump){
                    //    moveDirection = transform.forward * 2;
                    //    moveDirection.y = jumpSpeed;
                    //    ac.SetBool("jumping", true);
                    //    navAgent.enabled = false;
                    //}
                    //else{
                    //    ac.SetBool("jumping", false);
                    //}

                }
                //If the player isn't grounded move down
                else
                {
                    //navAgent.enabled = false;
                   // Debug.Log(playerName + " I'm floating");
                    moveDirection.y -= gravity * Time.fixedDeltaTime;
                    controller.Move(moveDirection * Time.fixedDeltaTime);

                }
                //if (jumping)
                //{
                   
                //    // moveDirection.y -= gravity * Time.deltaTime;
                //    // controller.Move(moveDirection * Time.deltaTime);
                //}

                //It's jumping time if we're not moving!
                //Space out next pos checks over time instead of frames to 
                //give a feel that AI isn't pausing
                if (nextPosCheck < Time.time)
                {
                    nextPosCheck = Time.time + Random.Range(.5f, 2.5f);

                    //If we haven't moved, and the navAgent's path is ready
                    if (prevPosition.AlmostEquals(transform.position, 1f) && !jumping)// && !navAgent.pathPending)
                   // if (prevPosition.AlmostEquals(transform.position, 1f) && !jumping)
                    {
                        jumpForwards(15f);
                        controller.Move(moveDirection * Time.fixedDeltaTime);
                    }
                    //We have moved since last check
                    else
                    {
                        if (navAgent.pathPending && navAgent.isOnNavMesh)
                        {
                            //If we're close to a player and not close to 
                            if (navAgent.remainingDistance <= 17 && isTargetPlayer)
                            {
                                if (transform.position.magnitude < 250f)
                                {
                                   
                                    //chance to jump to emulate a good player who shoots while jumping
                                    int randAttack = Random.Range(0, skillLevel);
                                    if (randAttack > 5)
                                    {
                                        //Jumpas randomly
                                        jumpRandomDir(15f);
                                    }

                                }
                                else
                                {
                                    //chance to jump to emulate a good player who shoots while jumping
                                    int randAttack = Random.Range(0, skillLevel);
                                    if (randAttack > 5)
                                    {
                                        jumpForwards(Random.Range(0f, 15f));
                                    }
                                }
                            }
                            //Not targeting player or close so one in 5 chance of
                            //jumping towards target. 
                            else
                            {
                                int randomNum = Random.Range(0, 5);
                                if(randomNum == 5)
                                {
                                    //Debug.Log("oops, jumoing " + playerName);
                                    jumpForwards(15f);
                                }
                            }
                        }
                        else
                        {
                            if (navAgent.pathPending)
                            {
                                jumpRandomDir(Random.Range(0f, 15f));
                                //Debug.Log("check back later homie, still pending my path " + playerName);
                            }
                            else
                            {
                                //Debug.Log("No jump cuz not on navmesh");
                            }
                        }
                    }

                    prevPosition = transform.position;
                }
            }
        }
    }
Exemple #48
0
    /// <summary>
    /// Creates the barricade.
    /// </summary>
    private void launchBarricade()
    {
        barricadeArray[arrayPointer].GetComponent <Barricade>().launch();
        barricadeArray[arrayPointer].GetComponent <SpriteRenderer> ().sprite = barricadeSprites [Random.Range(0, barricadeSprites.Length)];

        arrayPointer++;
        arrayPointer = arrayPointer % 8;
    }
Exemple #49
0
 private void SetTimerInterval() {
    _currentSpawnTime = Random.Range(_minSpawnTime, _maxSpawnTime);
 }
Exemple #50
0
 void PlayAnim()
 {
     GetComponent <Animation>().Play(Animation.name);
     Invoke("PlayAnim", Random.Range(LoopMin, LoopMax));
 }
 // Use this for initialization
 void Start() {
     remainingtime = Random.Range(4, 8);
     player1 = GameObject.FindGameObjectWithTag("Player");
 }
Exemple #52
0
 // Start is called before the first frame update
 void Start()
 {
     shotCounter = Random.Range(minTimeBetweenShots, maxTimeBetweenShots);
 }
 // Use this for initialization
 void Start()
 {
     animator = GetComponent<Animator>() as Animator;
     animator.speed = Random.Range(low, high);
 }
Exemple #54
0
        private void Initialize(UInt32 Id, string Name, string Description, string Type, string Owner, int Category,
                                int State, int UsersMax, string ModelName, string CCTs, int Score, List <string> pTags, bool AllowPets,
                                bool AllowPetsEating, bool AllowWalkthrough, bool Hidewall, RoomIcon Icon, string Password, string Wallpaper, string Floor,
                                string Landscape, RoomData RoomData, bool RightOverride, int walltickness, int floorthickness)
        {
            this.mDisposed   = false;
            this.Id          = Id;
            this.Name        = Name;
            this.Description = Description;
            this.Owner       = Owner;
            this.Category    = Category;
            this.Type        = Type;
            this.State       = State;
            this.UsersNow    = 0;
            this.UsersMax    = UsersMax;
            this.ModelName   = ModelName;
            this.CCTs        = CCTs;
            this.Score       = Score;

            tagCount  = 0;
            this.Tags = new ArrayList();
            foreach (string tag in pTags)
            {
                tagCount++;
                Tags.Add(tag);
            }

            this.AllowPets        = AllowPets;
            this.AllowPetsEating  = AllowPetsEating;
            this.AllowWalkthrough = AllowWalkthrough;
            this.Hidewall         = Hidewall;


            this.myIcon             = Icon;
            this.Password           = Password;
            this.Bans               = new Dictionary <UInt32, double>();
            this.Wallpaper          = Wallpaper;
            this.Floor              = Floor;
            this.Landscape          = Landscape;
            this.chatMessageManager = new ChatMessageManager();
            this.groups             = new QueuedDictionary <int, Group>();
            this.ActiveTrades       = new ArrayList();


            this.mCycleEnded = false;

            this.mRoomData         = RoomData;
            this.EveryoneGotRights = RightOverride;

            this.roomMessages     = new Queue();
            this.chatMessageQueue = new Queue();
            this.rnd = new Random();

            this.roomMessages       = new Queue();
            this.roomAlerts         = new Queue();
            this.roomBadge          = new Queue();
            this.roomKick           = new Queue();
            this.roomServerMessages = new Queue();
            this.IdleTime           = 0;
            this.RoomMuted          = false;
            this.WallThickness      = walltickness;
            this.FloorThickness     = floorthickness;

            this.gamemap          = new Gamemap(this);
            this.roomItemHandling = new RoomItemHandling(this);
            this.roomUserManager  = new RoomUserManager(this);
            this.wiredHandler     = new WiredHandler(this);

            LoadRights();
            GetRoomItemHandler().LoadFurniture();
            wiredHandler.LoadWired();
            GetGameMap().GenerateMaps();
            LoadMusic();
            //LoadBots();
            using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
            {
                if (dbClient.dbType == Database_Manager.Database.DatabaseType.MySQL)
                {
                    dbClient.runFastQuery("REPLACE INTO room_active VALUES (" + Id + ",1)");
                }
                else
                {
                    dbClient.runFastQuery("IF EXISTS (SELECT roomid FROM room_active WHERE roomid = " + Id + ") " +
                                          "UPDATE room_active SET active_users = 1 WHERE roomid = " + Id + " " +
                                          "ELSE " +
                                          "INSERT INTO room_active VALUES (" + Id + ",1)");
                }
            }

            ButterflyEnvironment.GetGame().GetRoomManager().QueueActiveRoomAdd(mRoomData);
        }
Exemple #55
0
        private void Two()
        {
            var random = new Random();
            var x      = random.Next(10);
            var y      = random.Next(10);

            if (y > 7)
            {
                x = random.Next(8);
                for (var i = y - 1; i < y + 2; i++)
                {
                    if (i < 0)
                    {
                        i++;
                    }
                    if (i > 9)
                    {
                        break;
                    }
                    for (var j = x - 1; j < x + 3; j++)
                    {
                        if (j < 0)
                        {
                            j++;
                        }
                        if (j > 9)
                        {
                            break;
                        }
                        if (BotField[i, j] != 0)
                        {
                            return;
                        }
                    }
                }
                for (var j = x; j < x + 2; j++)
                {
                    BotField[y, j] = 1;
                }
                this.Number++;
                return;
            }
            if (x > 7)
            {
                y = random.Next(8);
                for (var i = y - 1; i < y + 3; i++)
                {
                    if (i < 0)
                    {
                        i++;
                    }
                    if (i > 9)
                    {
                        break;
                    }
                    for (var j = x - 1; j < x + 2; j++)
                    {
                        if (j > 0)
                        {
                            j++;
                        }
                        if (j > 9)
                        {
                            break;
                        }
                        if (BotField[i, j] != 0)
                        {
                            return;
                        }
                    }
                }
                for (var i = y; i < y + 2; i++)
                {
                    BotField[i, x] = 1;
                }
                this.Number++;
                return;
            }
            var k = random.Next(1);

            if (k == 0)
            {
                for (var i = y - 1; i < y + 3; i++)
                {
                    if (i < 0)
                    {
                        i++;
                    }
                    if (i > 9)
                    {
                        break;
                    }
                    for (var j = x - 1; j < x + 2; j++)
                    {
                        if (j < 0)
                        {
                            j++;
                        }
                        if (j > 9)
                        {
                            break;
                        }
                        if (BotField[i, j] != 0)
                        {
                            return;
                        }
                    }
                }
                for (var i = y; i < y + 2; i++)
                {
                    BotField[i, x] = 1;
                }
                this.Number++;
            }
            else
            {
                for (var i = y - 1; i < y + 2; i++)
                {
                    if (i < 0)
                    {
                        i++;
                    }
                    if (i > 9)
                    {
                        break;
                    }
                    for (var j = x - 1; j < x + 3; j++)
                    {
                        if (j < 0)
                        {
                            j++;
                        }
                        if (j > 9)
                        {
                            break;
                        }
                        if (BotField[i, j] != 0)
                        {
                            return;
                        }
                    }
                }
                for (var j = x; j < x + 2; j++)
                {
                    BotField[y, j] = 1;
                }
                this.Number++;
            }
        }
Exemple #56
0
 // 랜덤 int 값 리턴
 int RandomInt(uint minNum, uint maxNum)
 {
     return((int)Random.Range(minNum, maxNum + 1));
 }
        public void AsynchronousSendMessageSyncReceiveMessage()
        {
            byte[] data   = new byte[36];
            Random rndGen = new Random();

            rndGen.NextBytes(data);

            byte[] length = new byte[4];
            Formatting.SizeToBytes(data.Length, length, 0);

            Message input = Formatting.BytesToMessage(data);

            ManualResetEvent evt = new ManualResetEvent(false);
            Uri    serverUri     = new Uri(SizedTcpTransportBindingElement.SizedTcpScheme + "://" + Environment.MachineName + ":" + Port);
            object channel       = ReflectionHelper.CreateInstance(
                typeof(SizedTcpTransportBindingElement),
                "JsonRpcOverTcp.Channels.SizedTcpRequestChannel",
                new ByteStreamMessageEncodingBindingElement().CreateMessageEncoderFactory().Encoder,
                BufferManager.CreateBufferManager(int.MaxValue, int.MaxValue),
                Mocks.GetChannelManagerBase(),
                new EndpointAddress(serverUri),
                serverUri);

            ReflectionHelper.CallMethod(channel, "Open");

            object state   = new object();
            bool   success = true;

            ReflectionHelper.CallMethod(channel, "BeginSendMessage", input, TimeSpan.FromMinutes(1), new AsyncCallback(delegate(IAsyncResult asyncResult)
            {
                try
                {
                    if (!Object.ReferenceEquals(asyncResult.AsyncState, state))
                    {
                        success = false;
                        Console.WriteLine("Error, state not preserved");
                    }
                    else
                    {
                        ReflectionHelper.CallMethod(channel, "EndSendMessage", asyncResult);
                        Message output = (Message)ReflectionHelper.CallMethod(channel, "ReceiveMessage", TimeSpan.FromMinutes(1));

                        try
                        {
                            Assert.Equal(2, this.server.ReceivedBytes.Count);
                            Assert.Equal(length, this.server.ReceivedBytes[0], new ArrayComparer <byte>());
                            Assert.Equal(data, this.server.ReceivedBytes[1], new ArrayComparer <byte>());

                            byte[] outputBytes = Formatting.MessageToBytes(output);
                            Assert.Equal(data, outputBytes, new ArrayComparer <byte>());
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine("Error: " + e);
                            success = false;
                        }
                    }
                }
                finally
                {
                    evt.Set();
                }
            }), state);

            evt.WaitOne();
            Assert.True(success, "Error in callback");
            ReflectionHelper.CallMethod(channel, "Close");
        }
		void Awake ()
		{
        transform.GetComponent<AudioSource>().pitch *= 1 + Random.Range(-randomPercent / 100, randomPercent / 100);
		}
        public void AsynchronousRequest()
        {
            byte[] data   = new byte[36];
            Random rndGen = new Random();

            rndGen.NextBytes(data);

            Message input = Formatting.BytesToMessage(data);

            ManualResetEvent evt = new ManualResetEvent(false);
            Uri    serverUri     = new Uri(SizedTcpTransportBindingElement.SizedTcpScheme + "://" + Environment.MachineName + ":" + Port);
            object channel       = ReflectionHelper.CreateInstance(
                typeof(SizedTcpTransportBindingElement),
                "JsonRpcOverTcp.Channels.SizedTcpRequestChannel",
                new ByteStreamMessageEncodingBindingElement().CreateMessageEncoderFactory().Encoder,
                BufferManager.CreateBufferManager(int.MaxValue, int.MaxValue),
                Mocks.GetChannelManagerBase(),
                new EndpointAddress(serverUri),
                serverUri);

            ChannelBase     channelBase    = (ChannelBase)channel;
            IRequestChannel requestChannel = (IRequestChannel)channel;

            channelBase.Open();

            object state   = new object();
            bool   success = true;

            requestChannel.BeginRequest(input, new AsyncCallback(delegate(IAsyncResult asyncResult)
            {
                try
                {
                    if (!Object.ReferenceEquals(asyncResult.AsyncState, state))
                    {
                        success = false;
                        Console.WriteLine("Error, state not preserved");
                    }
                    else
                    {
                        Message output = requestChannel.EndRequest(asyncResult);

                        try
                        {
                            byte[] outputBytes = Formatting.MessageToBytes(output);
                            Assert.Equal(data, outputBytes, new ArrayComparer <byte>());
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine("Error: " + e);
                            success = false;
                        }
                    }
                }
                finally
                {
                    evt.Set();
                }
            }), state);

            evt.WaitOne();
            Assert.True(success, "Error in callback");
            channelBase.Close();
        }
    private void Shoot()
    {
        readyToShoot = false;

        //Find the exact hit position using a raycast
        Ray ray = fpsCam.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0)); //Just a ray through the middle of your current view
        RaycastHit hit;

        //check if ray hits something
        Vector3 targetPoint;
        if (Physics.Raycast(ray, out hit))
            targetPoint = hit.point;
        else
            targetPoint = ray.GetPoint(75); //Just a point far away from the player

        //Calculate direction from attackPoint to targetPoint
        Vector3 directionWithoutSpread = targetPoint - attackPoint.position;

        //Calculate spread
        float x = Random.Range(-spread, spread);
        float y = Random.Range(-spread, spread);

        //Calculate new direction with spread
        Vector3 directionWithSpread = directionWithoutSpread + new Vector3(x, y, 0); //Just add spread to last direction

        //Instantiate bullet/projectile
        GameObject currentBullet = Instantiate(bullet, attackPoint.position, Quaternion.identity); //store instantiated bullet in currentBullet
        //Rotate bullet to shoot direction
        currentBullet.transform.forward = directionWithSpread.normalized;

        //Add forces to bullet
        currentBullet.GetComponent<Rigidbody>().AddForce(directionWithSpread.normalized * shootForce, ForceMode.Impulse);
        currentBullet.GetComponent<Rigidbody>().AddForce(fpsCam.transform.up * upwardForce, ForceMode.Impulse);
        if(currentBullet.gameObject.CompareTag("Enemy"))
        {
            Destroy(currentBullet.gameObject, 3);
        }
        if (currentBullet.gameObject.CompareTag("Thing"))
        {
            Destroy(currentBullet.gameObject, 3);
        }


        //Instantiate muzzle flash, if you have one
        if (muzzleFlash != null)
            Instantiate(muzzleFlash, attackPoint.position, Quaternion.identity);

        bulletsLeft--;
        bulletsShot++;

        //Invoke resetShot function (if not already invoked), with your timeBetweenShooting
        if (allowInvoke)
        {
            Invoke("ResetShot", timeBetweenShooting);
            allowInvoke = false;
            

            //Add recoil to player (should only be called once)
            playerRb.AddForce(-directionWithSpread.normalized * recoilForce, ForceMode.Impulse);
        }

        //if more than one bulletsPerTap make sure to repeat shoot function
        if (bulletsShot < bulletsPerTap && bulletsLeft > 0)
            Invoke("Shoot", timeBetweenShots);
    }