Inheritance: enchantment_base
 /// <summary>
 ///   Initializes the strategy with the specified nodes and cluster configuration
 /// </summary>
 /// <param name="nodes"> The nodes. </param>
 /// <param name="config"> The config. </param>
 public ExclusiveConnectionStrategy(Ring nodes, ClusterConfig config)
 {
     _nodes = nodes;
     _config = config;
     _connections = new ConcurrentStack<Connection>();
     _rndGen = new Random((int)DateTime.Now.Ticks);
 }
 public void AddRing(string id)
 {
     Ring x = new Ring();
     x.ID = id;
     x.Description = "A tunic";
     Rings.Add(x);
 }
Exemple #3
0
 public AuditoriumEvent(string name, Calendar calendar, Ring ring, Auditorium auditorium)
 {
     Name = name;
     Calendar = calendar;
     Ring = ring;
     Auditorium = auditorium;
 }
Exemple #4
0
 public Lesson(TeacherForDiscipline teacherForDiscipline, Calendar calendar,
               Ring ring, Auditorium auditorium)
 {
     TeacherForDiscipline = teacherForDiscipline;
     Calendar = calendar;
     Ring = ring;
     Auditorium = auditorium;
 }
Exemple #5
0
        /// <summary>
        /// Creates a new <c>RingCheck</c> that relates to the specified polygon ring.
        /// </summary>
        /// <param name="ring">The polygon ring the check relates to (not null).</param>
        /// <param name="types">The type(s) of check this item corresponds to</param>
        /// <exception cref="ArgumentNullException">If <paramref name="ring"/> is null</exception>
        internal RingCheck(Ring ring, CheckType types)
            : base(types)
        {
            if (ring==null)
                throw new ArgumentNullException();

            m_Ring = ring;
        }
Exemple #6
0
        private IPolygon GeneratePolygonFromRing(Ring ring)
        {
            IGeometryCollection pointPolygon = new PolygonClass();
            object missing = Type.Missing;  
            pointPolygon.AddGeometry(ring as IGeometry, ref missing, ref missing);
            IPolygon polyGonGeo = pointPolygon as IPolygon;
            polyGonGeo.SimplifyPreserveFromTo();

            return polyGonGeo;
        }
 /// <summary>
 /// Initializes the strategy with the specified nodes and cluster configuration
 /// </summary>
 /// <param name="nodes"> The nodes. </param>
 /// <param name="config"> The config. </param>
 public ExclusiveConnectionStrategy(Ring nodes, CqlConnectionStringBuilder config)
 {
     _nodes = nodes;
     _config = config;
     _connections = new ConcurrentStack<Connection>();
     _rndGen = new Random((int)DateTime.UtcNow.Ticks);
     _connectionCount = _nodes.Sum(n => n.ConnectionCount);
     if(_connectionCount > 0)
         _connections.PushRange(_nodes.SelectMany(n => n).ToArray());
 }
Exemple #8
0
 public Lesson(int lessonId,
               TeacherForDiscipline teacherForDiscipline, Calendar calendar,
               Ring ring, Auditorium auditorium, bool isActive)
 {
     LessonId = lessonId;
     TeacherForDiscipline = teacherForDiscipline;
     Calendar = calendar;
     Ring = ring;
     Auditorium = auditorium;
     IsActive = isActive;
 }
 public Ring Post(Ring ring)
 {
     if (ModelState.IsValid)
     {
         rings.Add(ring);
     } else {
         Response.StatusCode = (int)HttpStatusCode.BadRequest;
         ring = new Ring();
     }
     return ring;
 }
Exemple #10
0
    // Use this for initialization
    private void Start()
    {
        CircleCol = GetComponent<CircleCollider2D>();
        ring = GameObject.Instantiate(Resources.Load("Ring", typeof(Ring)), this.transform.position, Quaternion.identity) as Ring;
        floatingText = GameObject.Instantiate(Resources.Load("Score", typeof(FloatingScore)), this.transform.position, Quaternion.identity) as FloatingScore;
        currentRenderer = GetComponent<SpriteRenderer>();
        ring.circle = this;
        floatingText.Circle = this;
        ring.gameObject.SetActive(false);
        floatingText.gameObject.SetActive(false);

        tapSoundSource = this.GetComponent<AudioSource>();

        shadow = transform.GetChild(0).gameObject;
        shadowOriginalPosition = shadow.transform.position;

		if (GameController.IsHardMode) 
		{			
			origScale = gameObject.transform.localScale.x;
			GetComponent<SpriteRenderer> ().enabled = false;
			shadow.GetComponent<SpriteRenderer>().enabled = false;

			float llx, trx;
			float yll, ytr;

			if (name == "1" || name == "4" || name == "7") {
				llx = GameController.llCorner.x;
				trx = GameController.trCorner.x - ((GameController.boardWidth / 3f) * 2f);
			} else if (name == "2" || name == "5" || name == "8") {
				llx = GameController.llCorner.x + (GameController.boardWidth / 3f);
				trx = GameController.trCorner.x - (GameController.boardWidth / 3f);
			} else {
				llx = GameController.llCorner.x + ((GameController.boardWidth/3f)*2f);
				trx = GameController.trCorner.x;
			}

			if (name == "7" || name == "8" || name == "9") {
				yll = GameController.llCorner.y;
				ytr = GameController.trCorner.y - ((GameController.boardHeight / 3f)*2f);
			} else if (name == "4" || name == "5" || name == "6") {
				yll = GameController.llCorner.y + (GameController.boardHeight / 3f);
				ytr = GameController.trCorner.y - (GameController.boardHeight / 3f);
			} else {
				yll = GameController.llCorner.y + ((GameController.boardHeight / 3f)*2f);
				ytr = GameController.trCorner.y;
			}

			quadLLCor = new Vector2 (llx, yll);
			quadTRCor = new Vector2 (trx, ytr);
		}

        GameController.AddCircle(this);
    }
Exemple #11
0
 public void SetBuffering(int i)
 {
     if (running)
     {
         Stop();
         m_ring = new Ring<DataBlock>(i);
         Play();
     }
     else
     {
         m_ring = new Ring<DataBlock>(i);
     }
 }
Exemple #12
0
    /// <summary>
    /// レンダラに追加する
    /// </summary>
    void PushToRenderer()
    {
        var ring = new Ring();

        ring.pos = transform.position;
        ring.rotate = transform.rotation;
        ring.scale = transform.localScale;
        ring.innerPercentage = innerPercentage;
        ring.fanAngle = fanAngle;
        ring.color = color;

        ringRenderer.Push(ring);
    }
        public Ring Get(int id)
        {
            Ring ring;
            if (id >= 0 && id < rings.Count)
            {
                ring = rings[id];
            } else {
                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                ring = new Ring();
            }

            return ring;
        }
	void recreateItem(){
		if(selectedItem == healthIndex){
			sell[selectedItem] = new HealthPotion();
		}
		else if(selectedItem == manaIndex){
			sell[selectedItem] = new ManaPotion();
		}
		else if(selectedItem == amuletIndex){
			sell[selectedItem] = new Amulet();
		}
		else if(selectedItem == ringIndex){
			sell[selectedItem] = new Ring();
		}
	}
        /// <summary>
        /// Creates a new <c>SectionDivider</c> that relates to the specified section of line,
        /// with undefined polygon rings on left and right.
        /// </summary>
        /// <param name="line">The line this topological section partially coincides with.</param>
        /// <param name="from">The start position for the topological section.</param>
        /// <param name="to">The end position for the topological section.</param>
        internal SectionDivider(LineFeature line, ITerminal from, ITerminal to)
            : base(line, from, to)
        {
            m_Left = m_Right = null;

            if (from is Intersection)
                (from as Intersection).Add(line);
            else if (from is PointFeature)
                (from as PointFeature).AddReference(line);

            if (to is Intersection)
                (to as Intersection).Add(line);
            else if (to is PointFeature)
                (to as PointFeature).AddReference(line);
        }
		public void ShouldCreateAProperRingWithTheCorrectArguments()
		{
			var listPoints = new List<SimplePoint>
			{
				new SimplePoint(10, 20),
				new SimplePoint(15, 20),
				new SimplePoint(20, 20),
				new SimplePoint(10, 20)
			};

			(new Action(() => new Ring(listPoints))).Should().NotThrow();

			var testRing = new Ring(listPoints);
			testRing.Should().Not.Be.Null();
			testRing.Points.Should().Not.Be.Null();
			testRing.Points.Count.Should().Be(4);
		}
Exemple #17
0
        static void Main(string[] args)
        {
            // Задание 2.6
            /* Создать класс Ring (кольцо), описываемое координатами центра, внешним и внутренним радиусами, а
             * также свойствами, позволяющими узнать площадь кольца и суммарную длину внешней и внутренней
             * границ кольца. Обеспечить нахождение класса в заведомо корректном состоянии. */
            Console.WriteLine("\nЗадание 2.6 \n");

            Ring newRing = new Ring(0, 0, 7, 5);

            newRing.Print();

            Console.WriteLine("\nПлощадь кольца: {0}", newRing.AreaRing);
            Console.WriteLine("Длина внешнего кольца: {0}", newRing.LengthExternalRound);
            Console.WriteLine("Длина внутреннего кольца: {0}", newRing.LengthInternalRound);

            Console.ReadKey();
        }
        public async Task BalancedStrategyLowTreshold()
        {
            using(ShimsContext.Create())
            {
                //create cluster
                var config = new CqlConnectionStringBuilder {NewConnectionTreshold = 5};

                var cluster = new Cluster(config);

                //create nodes
                var n = new Node(IPAddress.Parse("127.0.0.1"), cluster);
                var n2 = new Node(IPAddress.Parse("127.0.0.2"), cluster);
                var n3 = new Node(IPAddress.Parse("127.0.0.3"), cluster);
                var n4 = new Node(IPAddress.Parse("127.0.0.4"), cluster);
                var nodes = new Ring();
                nodes.Update(new List<Node> {n, n2, n3, n4}, "RandomPartitioner",
                             new Logger(new NullLogger(), LogLevel.None));

                ShimAllConnections();

                var logger = cluster.LoggerManager.GetLogger("BalancedStrategyLowTresholdTest");

                IConnectionStrategy strategy = new BalancedConnectionStrategy(nodes, config);

                const int nr = 8;

                for(int i = 0; i < nr; i++)
                {
                    Connection connection;

                    using(logger.ThreadBinding())
                    {
                        connection = strategy.GetOrCreateConnection(ConnectionScope.Command, PartitionKey.None);
                    }

                    await
                        connection.SendRequestAsync(new QueryFrame("", CqlConsistency.Any, null), logger, 10,
                                                    CancellationToken.None);
                }

                Assert.AreEqual(nodes.Sum(nd => nd.ConnectionCount), nr);
                Assert.IsTrue(nodes.All(nd => nd.ConnectionCount == nr/4));
            }
        }
Exemple #19
0
            public Ring(Ring.Type pType, MaplePacket pPacket, string pOwnName = null)
            {
                RingType = pType;
                if (pType == Type.Marriage)
                {
                    int marriageID = pPacket.ReadInt();

                    int characterID = pPacket.ReadInt();
                    int partnerID = pPacket.ReadInt();
                    pPacket.ReadShort(); // Most likely 3, marriage type?
                    int characterItemID = pPacket.ReadInt();
                    int partnerItemID = pPacket.ReadInt();
                    string characterName = pPacket.ReadString(13);
                    string partnerName = pPacket.ReadString(13);

                    if (pOwnName != FriendName)
                    {
                        FriendID = partnerID;
                        FriendName = partnerName;
                        RingCashID1 = characterItemID;
                        RingCashID2 = partnerItemID;
                    }
                    else
                    {
                        FriendID = characterID;
                        FriendName = characterName;
                        RingCashID1 = partnerItemID;
                        RingCashID2 = characterItemID;
                    }
                }
                else
                {
                    FriendID = pPacket.ReadInt();
                    FriendName = pPacket.ReadString(13);
                    RingCashID1 = pPacket.ReadLong();
                    RingCashID2 = pPacket.ReadLong();

                    if (pType == Type.Friend)
                    {
                        int itemID = pPacket.ReadInt();
                    }

                }
            }
Exemple #20
0
        static void Test9()
        {
            Ring ring = new Ring(Field.Real, new string[] { "x1", "x2", "x3", "x4", "x5", "x6", "x7", "x8" });

            ring.FixOrder(new string[] { "x1", "x2", "x3", "x4", "x5", "x6", "x7", "x8" });


            Polynomial f1 = new Polynomial(ring);

            f1.AddTerm(1, new int[] { 3, 0, 0, 0, 0, 0, 0, 0 });
            f1.AddTerm(-1, new int[] { 0, 0, 0, 0, 0, 0, 0, 0 });

            Polynomial f2 = new Polynomial(ring);

            f2.AddTerm(1, new int[] { 0, 3, 0, 0, 0, 0, 0, 0 });
            f2.AddTerm(-1, new int[] { 0, 0, 0, 0, 0, 0, 0, 0 });

            Polynomial f3 = new Polynomial(ring);

            f3.AddTerm(1, new int[] { 0, 0, 3, 0, 0, 0, 0, 0 });
            f3.AddTerm(-1, new int[] { 0, 0, 0, 0, 0, 0, 0, 0 });

            Polynomial f4 = new Polynomial(ring);

            f4.AddTerm(1, new int[] { 0, 0, 0, 3, 0, 0, 0, 0 });
            f4.AddTerm(-1, new int[] { 0, 0, 0, 0, 0, 0, 0, 0 });

            Polynomial f5 = new Polynomial(ring);

            f5.AddTerm(1, new int[] { 0, 0, 0, 0, 3, 0, 0, 0 });
            f5.AddTerm(-1, new int[] { 0, 0, 0, 0, 0, 0, 0, 0 });

            Polynomial f6 = new Polynomial(ring);

            f6.AddTerm(1, new int[] { 0, 0, 0, 0, 0, 3, 0, 0 });
            f6.AddTerm(-1, new int[] { 0, 0, 0, 0, 0, 0, 0, 0 });

            Polynomial f7 = new Polynomial(ring);

            f7.AddTerm(1, new int[] { 0, 0, 0, 0, 0, 0, 3, 0 });
            f7.AddTerm(-1, new int[] { 0, 0, 0, 0, 0, 0, 0, 0 });

            Polynomial f8 = new Polynomial(ring);

            f8.AddTerm(1, new int[] { 0, 0, 0, 0, 0, 0, 0, 3 });
            f8.AddTerm(-1, new int[] { 0, 0, 0, 0, 0, 0, 0, 0 });

            Polynomial f9 = new Polynomial(ring);

            f9.AddTerm(1, new int[] { 2, 0, 0, 0, 0, 0, 0, 0 });
            f9.AddTerm(1, new int[] { 1, 1, 0, 0, 0, 0, 0, 0 });
            f9.AddTerm(1, new int[] { 0, 2, 0, 0, 0, 0, 0, 0 });


            Polynomial f10 = new Polynomial(ring);

            f10.AddTerm(1, new int[] { 0, 2, 0, 0, 0, 0, 0, 0 });
            f10.AddTerm(1, new int[] { 0, 1, 1, 0, 0, 0, 0, 0 });
            f10.AddTerm(1, new int[] { 0, 0, 2, 0, 0, 0, 0, 0 });

            Polynomial f11 = new Polynomial(ring);

            f11.AddTerm(1, new int[] { 0, 0, 2, 0, 0, 0, 0, 0 });
            f11.AddTerm(1, new int[] { 0, 0, 1, 1, 0, 0, 0, 0 });
            f11.AddTerm(1, new int[] { 0, 0, 0, 2, 0, 0, 0, 0 });


            Polynomial f12 = new Polynomial(ring);

            f12.AddTerm(1, new int[] { 0, 0, 0, 2, 0, 0, 0, 0 });
            f12.AddTerm(1, new int[] { 0, 0, 0, 1, 1, 0, 0, 0 });
            f12.AddTerm(1, new int[] { 0, 0, 0, 0, 2, 0, 0, 0 });

            Polynomial f13 = new Polynomial(ring);

            f13.AddTerm(1, new int[] { 0, 0, 0, 0, 2, 0, 0, 0 });
            f13.AddTerm(1, new int[] { 0, 0, 0, 0, 1, 1, 0, 0 });
            f13.AddTerm(1, new int[] { 0, 0, 0, 0, 0, 2, 0, 0 });

            Polynomial f14 = new Polynomial(ring);

            f14.AddTerm(1, new int[] { 0, 0, 0, 0, 0, 2, 0, 0 });
            f14.AddTerm(1, new int[] { 0, 0, 0, 0, 0, 1, 1, 0 });
            f14.AddTerm(1, new int[] { 0, 0, 0, 0, 0, 0, 2, 0 });

            Polynomial f15 = new Polynomial(ring);

            f15.AddTerm(1, new int[] { 0, 0, 0, 0, 0, 0, 2, 0 });
            f15.AddTerm(1, new int[] { 0, 0, 0, 0, 0, 0, 1, 1 });
            f15.AddTerm(1, new int[] { 0, 0, 0, 0, 0, 0, 0, 2 });

            Ideal I = new Ideal(new Polynomial[] { f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15 }, ring);

            Console.WriteLine("__________Gröbner Basis__________________");
            var gb = I.GröbnerBasis();

            foreach (var p in gb)
            {
                Console.WriteLine(p);
            }

            Console.WriteLine("_________Minimal Gröbner Basis___________________");

            var minimal = I.MinimalGröbnerBasis();

            foreach (var p in minimal)
            {
                Console.WriteLine(p);
            }

            Console.WriteLine("______________Reduced Gröbner Basis______________");


            var reduced = I.ReducedGrobnerBasis();

            foreach (var p in reduced)
            {
                Console.WriteLine(p);
            }

            Console.WriteLine("__________Membership__________________");
            Console.WriteLine(I.Member(f1));
        }
Exemple #21
0
 private static void out_rings(object sender, EventArgsCommand e)
 {
     for (var i = 0; i < 100; i++)
     {
         try
         {
             Item it = new Ring(i);
             if (it.Name != "Error Item")
                 Console.WriteLine(i + "| " + it.Name);
         }
         catch
         {
         }
     }
 }
	public void recreateEquipItem(int x, int y, int i){
		Item item;
		if(PlayerPrefs.GetString("Equiped Item type" + i) == "Axe"){
			item = new Axe();
			item.useItem(player);
			//add item to axe slot
		}
		else if(PlayerPrefs.GetString("Equiped Item type" + i) == "Ring"){
			item = new Ring();
			item.useItem(player);
			//add item to ring slot);
		}
		else if(PlayerPrefs.GetString("Equiped Item type" + i) == "Chest"){
			item = new Chest();
			item.useItem(player);
			//add item to chest slot
		}
		else if(PlayerPrefs.GetString("Equiped Item type" + i) == "Boots"){
			item = new Boots();
			item.useItem(player);
			//add item to boots slot
		}
		else if(PlayerPrefs.GetString("Equiped Item type" + i) == "Amulet"){
			item = new Amulet();
			item.useItem(player);
			//add item to amulet slot
		}
		else if(PlayerPrefs.GetString("Equiped Item type" + i) == "Sword"){
			item = new Sword();
			item.useItem(player);
			//add item to sword slot
		}
	}
Exemple #23
0
        public static Polygon ParsePolygon(string wkt)
        {
            string[] parts = wkt.Split(new string[] {"((","))"}, StringSplitOptions.None);

            if (parts[0].TrimEnd(' ') != "POLYGON")
            {
                throw new ArgumentException(string.Format("Unexpected WKT, expected 'POLYGON', found '{0}'",
                                                          parts[0]));
            }

            Polygon p = new Polygon();

            // split by ring
            string[] ringwkts = parts[1].Split(new string[] {"),(","), ("}, StringSplitOptions.None);

            for (int ii=0; ii<ringwkts.Length; ii++)
            {
                // trim off parens
                string ringwkt =  ringwkts[ii].Trim(new char[] {'(',')'});

                Ring r = new Ring();

                // split by coordinate
                string[] coords = ringwkt.Split(',');

                foreach (string coord in coords)
                {
                    r.Points.Add(SplitPoint(coord));
                }

                if (!r.IsClosed) r.Close();

                p.Rings.Add(r);
            }

            return p;
        }
Exemple #24
0
        public static string CreateFromRectangle(Rectangle rectangle)
        {
            Polygon p = new Polygon();

            Ring r = new Ring();
            r.Points.Add(rectangle.Min.Clone());
            r.Points.Add(new Point(rectangle.Min.X, rectangle.Max.Y));
            r.Points.Add(rectangle.Max.Clone());
            r.Points.Add(new Point(rectangle.Max.X, rectangle.Min.Y));
            r.Close();

            p.Rings.Add(r);

            return CreateFromPolygon(p);
        }
Exemple #25
0
 public AGSRing(Ring srcRing) : base(srcRing)
 {
 }
Exemple #26
0
        private static gView.Framework.Geometry.IRing ToRing(Ring ring, ref bool complex)
        {
            gView.Framework.Geometry.Ring r = new gView.Framework.Geometry.Ring();
            if (ring != null && ring.PointArray != null)
            {
                foreach (Point point in ring.PointArray)
                {
                    if (point is PointN)
                    {
                        r.AddPoint(ToPoint((PointN)point));
                    }
                }
            }
            else if (ring != null && ring.SegmentArray != null)
            {
                complex = true;
                foreach (Segment segment in ring.SegmentArray)
                {
                    #region Line
                    if (segment is Line &&
                        (((Line)segment).FromPoint is PointN &&
                         ((Line)segment).ToPoint is PointN))
                    {
                        gView.Framework.Geometry.IPoint p1 = ToPoint((PointN)((Line)segment).FromPoint);
                        gView.Framework.Geometry.IPoint p2 = ToPoint((PointN)((Line)segment).ToPoint);

                        if (r.PointCount == 0)
                        {
                            r.AddPoint(p1);
                            r.AddPoint(p2);
                        }
                        else
                        {
                            if (r[r.PointCount - 1].Equals(p1))
                            {
                                r.AddPoint(p2);
                            }
                            else
                            {
                                r.AddPoint(p1);
                                r.AddPoint(p2);
                            }
                        }
                    }
                    #endregion
                    #region CircularArc
                    else if (segment is CircularArc &&
                             (((CircularArc)segment).FromPoint is PointN &&
                              ((CircularArc)segment).ToPoint is PointN))
                    {
                        gView.Framework.Geometry.IPoint p1 = ToPoint((PointN)((CircularArc)segment).FromPoint);
                        gView.Framework.Geometry.IPoint p2 = ToPoint((PointN)((CircularArc)segment).ToPoint);

                        if (r.PointCount == 0)
                        {
                            r.AddPoint(p1);
                            r.AddPoint(p2);
                        }
                        else
                        {
                            if (r[r.PointCount - 1].Equals(p1))
                            {
                                r.AddPoint(p2);
                            }
                            else
                            {
                                r.AddPoint(p1);
                                r.AddPoint(p2);
                            }
                        }
                    }
                    #endregion
                }
            }
            return(r);
        }
Exemple #27
0
        public static IGroupElement CreateFacadesFromPolygon(IFeature ifeature_0, IFeature3DProperties ifeature3DProperties_0, clsTextureGroup clsTextureGroup_0, ISurface isurface_0, string string_0, IPolygon ipolygon_0, bool bool_0)
        {
            IGroupElement groupElement = null;
            IGroupElement result;

            try
            {
                IEncode3DProperties encode3DProperties = new GeometryEnvironment() as IEncode3DProperties;
                IGroupElement       groupElement2      = new GroupElement() as IGroupElement;
                if (modFacades.m_limitAngle == 0.0)
                {
                    modFacades.m_limitAngle = 0.5235987666666666;
                }
                IGeometry geometry = null;
                if (ifeature_0 != null)
                {
                    if (ifeature3DProperties_0 != null && bool_0)
                    {
                        ifeature3DProperties_0.ApplyFeatureProperties(ifeature_0, out geometry, false);
                    }
                    else
                    {
                        geometry = ifeature_0.Shape;
                    }
                }
                else if (ipolygon_0 != null)
                {
                    geometry = ipolygon_0;
                }
                if (geometry == null)
                {
                    result = null;
                    return(result);
                }
                if (!(geometry is IMultiPatch))
                {
                }
                IEnvelope         envelope         = geometry.Envelope;
                double            num              = envelope.ZMin;
                ISpatialReference spatialReference = BuildingProperty.Scene.SpatialReference;
                geometry.Project(spatialReference);
                string a = num.ToString();
                if (a.Equals("非数字"))
                {
                    num = 0.0;
                }
                double num2 = 0.0;
                if (ifeature3DProperties_0 != null)
                {
                    I3DProperties i3DProperties = ifeature3DProperties_0 as I3DProperties;
                    if (i3DProperties.OffsetExpressionString.Length > 0)
                    {
                        try
                        {
                            num2 = Convert.ToDouble(i3DProperties.OffsetExpressionString);
                        }
                        catch
                        {
                        }
                    }
                    if (geometry is IPolygon)
                    {
                        num += num2;
                    }
                }
                IGeometryCollection geometryCollection = geometry as IGeometryCollection;
                int geometryCount = geometryCollection.GeometryCount;
                int num3;
                if (geometry is IMultiPatch)
                {
                    geometryCount = geometryCollection.GeometryCount;
                    num3          = geometryCollection.GeometryCount * 2 / 3;
                    modFacades.m_extrusionHeight = geometry.Envelope.ZMax - geometry.Envelope.ZMin;
                }
                else
                {
                    num3          = 0;
                    geometryCount = geometryCollection.GeometryCount;
                }
                if (modFacades.m_extrusionHeight < 1.0)
                {
                    modFacades.m_extrusionHeight = 1.0;
                }
                IPoint point = null;
                double num4  = 0.0;
                double num5  = 0.0;
                double num6  = 0.0;
                object value = Missing.Value;
                for (int i = num3; i < geometryCount; i++)
                {
                    IGeometry        geometry2    = geometryCollection.get_Geometry(i);
                    esriGeometryType geometryType = geometry2.GeometryType;
                    if (geometryType == esriGeometryType.esriGeometryRing || geometryType == esriGeometryType.esriGeometryPolyline)
                    {
                        IPointCollection pointCollection = geometry2 as IPointCollection;
                        int pointCount = pointCollection.PointCount;
                        if (pointCount >= 2)
                        {
                            int                 num7 = 0;
                            int                 num8 = 1;
                            bool                flag = false;
                            IPointCollection    pointCollection2;
                            double              m;
                            IMultiPatch         multiPatch;
                            IGeometryCollection geometryCollection2;
                            IZAware             iZAware;
                            IMAware             iMAware;
                            IElement            element;
                            while (!flag)
                            {
                                bool flag2 = false;
                                while (num8 < pointCount && !flag2)
                                {
                                    if (num8 - num7 == 1)
                                    {
                                        IPoint point2 = pointCollection.get_Point(num7);
                                        point = pointCollection.get_Point(num8);
                                        num5  = point.X - point2.X;
                                        num6  = point.Y - point2.Y;
                                        num4  = Math.Sqrt(num5 * num5 + num6 * num6);
                                        if (isurface_0 != null)
                                        {
                                            num  = isurface_0.get_Z(point.X, point.Y);
                                            num += num2;
                                        }
                                    }
                                    else
                                    {
                                        IPoint point2 = point;
                                        double num9   = num5;
                                        double num10  = num6;
                                        point = pointCollection.get_Point(num8);
                                        if (isurface_0 != null)
                                        {
                                            num  = isurface_0.get_Z(point.X, point.Y);
                                            num += num2;
                                        }
                                        num5 = point.X - point2.X;
                                        num6 = point.Y - point2.Y;
                                        double num11 = Math.Sqrt(num9 * num9 + num10 * num10);
                                        double num12 = Math.Sqrt(num5 * num5 + num6 * num6);
                                        double num13 = (num9 * num5 + num10 * num6) / (num11 * num12);
                                        if (num13 < Math.Cos(modFacades.m_limitAngle))
                                        {
                                            flag2 = true;
                                            break;
                                        }
                                        num4 += num12;
                                    }
                                    num8++;
                                }
                                if (flag2)
                                {
                                    num8--;
                                }
                                else
                                {
                                    num8--;
                                }
                                pointCollection2 = new TriangleStrip();
                                double num14 = 0.0;
                                for (int j = num7; j <= num8; j++)
                                {
                                    if (j > 0)
                                    {
                                        IPoint point2 = point;
                                        point  = pointCollection.get_Point(j);
                                        num5   = point.X - point2.Y;
                                        num6   = point.Y - point2.Y;
                                        num14 += Math.Sqrt(num5 * num5 + num6 * num6);
                                    }
                                    else
                                    {
                                        point = pointCollection.get_Point(j);
                                    }
                                    point.Z = num;
                                    m       = 0.0;
                                    encode3DProperties.PackTexture2D(num14 / num4, 0.0, out m);
                                    point.M = m;
                                    IClone clone = point as IClone;
                                    pointCollection2.AddPoint(clone.Clone() as IPoint, ref value, ref value);
                                    point.Z = num + modFacades.m_extrusionHeight;
                                    m       = 0.0;
                                    encode3DProperties.PackTexture2D(num14 / num4, -1.0, out m);
                                    point.M = m;
                                    pointCollection2.AddPoint(clone.Clone() as IPoint, ref value, ref value);
                                }
                                multiPatch          = new MultiPatch() as IMultiPatch;
                                geometryCollection2 = (multiPatch as IGeometryCollection);
                                iZAware             = (multiPatch as IZAware);
                                iZAware.ZAware      = true;
                                iMAware             = (multiPatch as IMAware);
                                iMAware.MAware      = true;
                                geometryCollection2.AddGeometry(pointCollection2 as IGeometry, ref value, ref value);
                                if (clsTextureGroup_0 != null)
                                {
                                    int index = modFacades.FindTextureByAspect(clsTextureGroup_0, num4 / modFacades.m_extrusionHeight);
                                    element = modFacades.CreateElement(multiPatch, clsTextureGroup_0.Symbols[index], string_0);
                                }
                                else
                                {
                                    element = modFacades.CreateElement(multiPatch, null, string_0);
                                }
                                if (element != null)
                                {
                                    groupElement2.AddElement(element);
                                }
                                num7 = num8;
                                num8 = num7 + 1;
                                if (num7 >= pointCount - 1)
                                {
                                    flag = true;
                                }
                            }
                            IVector3D vector3D = new Vector3D() as IVector3D;
                            vector3D.XComponent = 0.0;
                            vector3D.YComponent = 0.0;
                            vector3D.ZComponent = 1.0;
                            m = 0.0;
                            encode3DProperties.PackNormal(vector3D, out m);
                            pointCollection2 = new Ring();
                            for (int j = 0; j <= pointCount - 1; j++)
                            {
                                IPoint point3 = pointCollection.get_Point(j);
                                point3.Z = num + modFacades.m_extrusionHeight;
                                point3.M = 0.0;
                                IClone clone = point3 as IClone;
                                pointCollection2.AddPoint(clone.Clone() as IPoint, ref value, ref value);
                            }
                            IRing ring = pointCollection2 as IRing;
                            ring.Close();
                            multiPatch          = new MultiPatch() as IMultiPatch;
                            geometryCollection2 = (multiPatch as IGeometryCollection);
                            iZAware             = (multiPatch as IZAware);
                            iZAware.ZAware      = true;
                            iMAware             = (multiPatch as IMAware);
                            iMAware.MAware      = true;
                            geometryCollection2.AddGeometry(pointCollection2 as IGeometry, ref value, ref value);
                            multiPatch.PutRingType(pointCollection2 as IRing, esriMultiPatchRingType.esriMultiPatchOuterRing);
                            if (clsTextureGroup_0 != null)
                            {
                                element = modFacades.CreateElement(multiPatch, clsTextureGroup_0.RoofSymbol, string_0 + ";ROOFCOLOR=" + clsTextureGroup_0.RoofColorRGB.ToString());
                            }
                            else
                            {
                                element = modFacades.CreateElement(multiPatch, null, string_0 + ";ROOFCOLOR=1");
                            }
                            if (element != null)
                            {
                                groupElement2.AddElement(element);
                            }
                        }
                    }
                }
                if (groupElement2 != null)
                {
                    IElementProperties elementProperties = groupElement2 as IElementProperties;
                    elementProperties.Name = string_0;
                }
                groupElement = groupElement2;
                result       = groupElement;
                return(result);
            }
            catch
            {
            }
            result = groupElement;
            return(result);
        }
Exemple #28
0
        public new void BeforeRender(Scene scene)
        {
            if (vanillaMoonParticles == null)
            {
                vanillaMoonParticles = (Engine.Scene as Overworld)?.Entities.OfType <MoonParticle3D>().First();
            }

            string path;

            try {
                path = Path.Combine("Maps", SaveData.Instance?.LastArea.GetSID() ?? "").Replace('\\', '/');
            } catch (ArgumentException) {
                path = "Maps";
            }
            string SIDToUse = SaveData.Instance?.LastArea.GetSID() ?? "";
            bool   fadingIn = true;

            // Check if we're changing any mountain parameter
            // If so, we want to fade out and then back in
            if (!(SaveData.Instance?.LastArea.GetSID() ?? "").Equals(PreviousSID))
            {
                MapMetaMountain oldMountain = null;
                MapMetaMountain newMountain = null;
                if (SaveData.Instance != null && Everest.Content.TryGet(path, out ModAsset asset1))
                {
                    MapMeta meta;
                    if (asset1 != null && (meta = asset1.GetMeta <MapMeta>()) != null && meta.Mountain != null)
                    {
                        newMountain = meta.Mountain;
                    }
                }
                string oldPath;
                try {
                    oldPath = Path.Combine("Maps", PreviousSID ?? "").Replace('\\', '/');
                } catch (ArgumentException) {
                    oldPath = "Maps";
                }
                if (SaveData.Instance != null && Everest.Content.TryGet(oldPath, out asset1))
                {
                    MapMeta meta;
                    if (asset1 != null && (meta = asset1.GetMeta <MapMeta>()) != null && meta.Mountain != null)
                    {
                        oldMountain = meta.Mountain;
                    }
                }

                if (oldMountain?.MountainModelDirectory != newMountain?.MountainModelDirectory ||
                    oldMountain?.MountainTextureDirectory != newMountain?.MountainTextureDirectory ||
                    oldMountain?.StarFogColor != newMountain?.StarFogColor ||
                    !arrayEqual(oldMountain?.StarStreamColors, newMountain?.StarStreamColors) ||
                    !arrayEqual(oldMountain?.StarBeltColors1, newMountain?.StarBeltColors1) ||
                    !arrayEqual(oldMountain?.StarBeltColors2, newMountain?.StarBeltColors2))
                {
                    if (fade != 1f)
                    {
                        SIDToUse = PreviousSID;
                        path     = oldPath;
                        fade     = Calc.Approach(fade, 1f, Engine.DeltaTime * 4f);
                        fadingIn = false;
                    }
                    else
                    {
                        // How long we want it to stay opaque before fading back in
                        fadeHoldCountdown = .3f;
                    }
                }
            }

            if (fadingIn && fade != 0f)
            {
                if (fadeHoldCountdown <= 0)
                {
                    fade = Calc.Approach(fade, 0f, Engine.DeltaTime * 4f);
                }
                else
                {
                    fadeHoldCountdown -= Engine.DeltaTime;
                }
            }

            if (SaveData.Instance != null && Everest.Content.TryGet(path, out ModAsset asset))
            {
                MapMeta meta;
                if (asset != null && (meta = asset.GetMeta <MapMeta>()) != null && meta.Mountain != null && hasCustomSettings(meta))
                {
                    MountainResources resources = MTNExt.MountainMappings[path];

                    ResetRenderTargets();
                    Quaternion rotation = Camera.Rotation;
                    if (ignoreCameraRotation)
                    {
                        rotation = lastCameraRotation;
                    }
                    Matrix matrix  = Matrix.CreatePerspectiveFieldOfView((float)Math.PI / 4f, (float)Engine.Width / (float)Engine.Height, 0.25f, 50f);
                    Matrix matrix2 = Matrix.CreateTranslation(-Camera.Position) * Matrix.CreateFromQuaternion(rotation);
                    Matrix matrix3 = matrix2 * matrix;
                    Forward = Vector3.Transform(Vector3.Forward, Camera.Rotation.Conjugated());
                    Engine.Graphics.GraphicsDevice.SetRenderTarget(buffer);

                    if (StarEase < 1f)
                    {
                        Matrix matrix4 = Matrix.CreateTranslation(0f, 5f - Camera.Position.Y * 1.1f, 0f) * Matrix.CreateFromQuaternion(rotation) * matrix;

                        if (currState == nextState)
                        {
                            (resources.MountainStates?[currState] ?? mountainStates[currState]).Skybox.Draw(matrix4, Color.White);
                        }
                        else
                        {
                            (resources.MountainStates?[currState] ?? mountainStates[currState]).Skybox.Draw(matrix4, Color.White);
                            (resources.MountainStates?[currState] ?? mountainStates[currState]).Skybox.Draw(matrix4, Color.White * easeState);
                        }
                        if (currState != nextState)
                        {
                            GFX.FxMountain.Parameters["ease"].SetValue(easeState);
                            GFX.FxMountain.CurrentTechnique = GFX.FxMountain.Techniques["Easing"];
                        }
                        else
                        {
                            GFX.FxMountain.CurrentTechnique = GFX.FxMountain.Techniques["Single"];
                        }
                        Engine.Graphics.GraphicsDevice.DepthStencilState = DepthStencilState.Default;
                        Engine.Graphics.GraphicsDevice.BlendState        = BlendState.AlphaBlend;
                        Engine.Graphics.GraphicsDevice.RasterizerState   = MountainRasterizer;
                        GFX.FxMountain.Parameters["WorldViewProj"].SetValue(matrix3);
                        GFX.FxMountain.Parameters["fog"].SetValue(customFog.TopColor.ToVector3());
                        Engine.Graphics.GraphicsDevice.Textures[0]      = (resources.MountainStates?[currState] ?? mountainStates[currState]).TerrainTexture.Texture;
                        Engine.Graphics.GraphicsDevice.SamplerStates[0] = SamplerState.LinearClamp;
                        if (currState != nextState)
                        {
                            Engine.Graphics.GraphicsDevice.Textures[1]      = (resources.MountainStates?[nextState] ?? mountainStates[nextState]).TerrainTexture.Texture;
                            Engine.Graphics.GraphicsDevice.SamplerStates[1] = SamplerState.LinearClamp;
                        }
                        (resources.MountainTerrain ?? MTN.MountainTerrain).Draw(GFX.FxMountain);
                        GFX.FxMountain.Parameters["WorldViewProj"].SetValue(Matrix.CreateTranslation(CoreWallPosition) * matrix3);
                        (resources.MountainCoreWall ?? MTN.MountainCoreWall).Draw(GFX.FxMountain);
                        GFX.FxMountain.Parameters["WorldViewProj"].SetValue(matrix3);
                        Engine.Graphics.GraphicsDevice.Textures[0]      = (resources.MountainStates?[currState] ?? mountainStates[currState]).BuildingsTexture.Texture;
                        Engine.Graphics.GraphicsDevice.SamplerStates[0] = SamplerState.LinearClamp;
                        if (currState != nextState)
                        {
                            Engine.Graphics.GraphicsDevice.Textures[1]      = (resources.MountainStates?[nextState] ?? mountainStates[nextState]).BuildingsTexture.Texture;
                            Engine.Graphics.GraphicsDevice.SamplerStates[1] = SamplerState.LinearClamp;
                        }
                        (resources.MountainBuildings ?? MTN.MountainBuildings).Draw(GFX.FxMountain);
                        customFog.Draw(matrix3);
                    }

                    if (StarEase > 0f)
                    {
                        Draw.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null);
                        Draw.Rect(0f, 0f, buffer.Width, buffer.Height, Color.Black * Ease.CubeInOut(Calc.ClampedMap(StarEase, 0f, 0.6f)));
                        Draw.SpriteBatch.End();
                        Matrix matrix5 = Matrix.CreateTranslation(starCenter - Camera.Position) * Matrix.CreateFromQuaternion(rotation) * matrix;
                        float  alpha   = Calc.ClampedMap(StarEase, 0.8f, 1f);
                        customStarsky.Draw(matrix5, CullCCRasterizer, alpha);
                        customStarfog.Draw(matrix5, CullCCRasterizer, alpha);
                        customStardots0.Draw(matrix5, CullCCRasterizer, alpha);
                        customStarstream0.Draw(matrix5, CullCCRasterizer, alpha);
                        customStarstream1.Draw(matrix5, CullCCRasterizer, alpha);
                        customStarstream2.Draw(matrix5, CullCCRasterizer, alpha);
                        Engine.Graphics.GraphicsDevice.DepthStencilState = DepthStencilState.Default;
                        Engine.Graphics.GraphicsDevice.BlendState        = BlendState.AlphaBlend;
                        Engine.Graphics.GraphicsDevice.RasterizerState   = CullCRasterizer;
                        Engine.Graphics.GraphicsDevice.Textures[0]       = (resources.MountainMoonTexture ?? MTN.MountainMoonTexture).Texture;
                        Engine.Graphics.GraphicsDevice.SamplerStates[0]  = SamplerState.LinearClamp;
                        GFX.FxMountain.CurrentTechnique = GFX.FxMountain.Techniques["Single"];
                        GFX.FxMountain.Parameters["WorldViewProj"].SetValue(matrix3);
                        GFX.FxMountain.Parameters["fog"].SetValue(fog.TopColor.ToVector3());
                        (resources.MountainMoon ?? MTN.MountainMoon).Draw(GFX.FxMountain);
                        float  num     = birdTimer * 0.2f;
                        Matrix matrix6 = Matrix.CreateScale(0.25f) * Matrix.CreateRotationZ((float)Math.Cos(num * 2f) * 0.5f) * Matrix.CreateRotationX(0.4f + (float)Math.Sin(num) * 0.05f) * Matrix.CreateRotationY(0f - num - (float)Math.PI / 2f) * Matrix.CreateTranslation((float)Math.Cos(num) * 2.2f, 31f + (float)Math.Sin(num * 2f) * 0.8f, (float)Math.Sin(num) * 2.2f);
                        GFX.FxMountain.Parameters["WorldViewProj"].SetValue(matrix6 * matrix3);
                        GFX.FxMountain.Parameters["fog"].SetValue(fog.TopColor.ToVector3());
                        (resources.MountainBird ?? MTN.MountainBird).Draw(GFX.FxMountain);
                    }

                    DrawBillboards(matrix3, scene.Tracker.GetComponents <Billboard>());

                    if (StarEase < 1f)
                    {
                        customFog2.Draw(matrix3, CullCRasterizer);
                    }

                    if (DrawDebugPoints && DebugPoints.Count > 0)
                    {
                        GFX.FxDebug.World              = Matrix.Identity;
                        GFX.FxDebug.View               = matrix2;
                        GFX.FxDebug.Projection         = matrix;
                        GFX.FxDebug.TextureEnabled     = false;
                        GFX.FxDebug.VertexColorEnabled = true;
                        VertexPositionColor[] array = DebugPoints.ToArray();
                        foreach (EffectPass pass in GFX.FxDebug.CurrentTechnique.Passes)
                        {
                            pass.Apply();
                            Engine.Graphics.GraphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, array, 0, array.Length / 3);
                        }
                    }
                    GaussianBlur.Blur((RenderTarget2D)buffer, blurA, blurB, 0.75f, clear: true, samples: GaussianBlur.Samples.Five);

                    Draw.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null);
                    Draw.Rect(-10f, -10f, 1940f, 1100f, Color.Black * fade);
                    Draw.SpriteBatch.End();

                    // Initialize new custom fog and star belt when we switch between maps
                    if (!(SIDToUse).Equals(PreviousSID))
                    {
                        customFog         = new Ring(6f, -1f, 20f, 0f, 24, Color.White, resources.MountainFogTexture ?? MTN.MountainFogTexture);
                        customFog2        = new Ring(6f, -4f, 10f, 0f, 24, Color.White, resources.MountainFogTexture ?? MTN.MountainFogTexture);
                        customStarsky     = new Ring(18f, -18f, 20f, 0f, 24, Color.White, Color.Transparent, resources.MountainSpaceTexture ?? MTN.MountainStarSky);
                        customStarfog     = new Ring(10f, -18f, 19.5f, 0f, 24, resources.StarFogColor ?? Calc.HexToColor("020915"), Color.Transparent, resources.MountainFogTexture ?? MTN.MountainFogTexture);
                        customStardots0   = new Ring(16f, -18f, 19f, 0f, 24, Color.White, Color.Transparent, resources.MountainSpaceStarsTexture ?? MTN.MountainStars, 4f);
                        customStarstream0 = new Ring(5f, -8f, 18.5f, 0.2f, 80, resources.StarStreamColors?[0] ?? Color.Black, resources.MountainStarStreamTexture ?? MTN.MountainStarStream);
                        customStarstream1 = new Ring(4f, -6f, 18f, 1f, 80, resources.StarStreamColors?[1] ?? Calc.HexToColor("9228e2") * 0.5f, resources.MountainStarStreamTexture ?? MTN.MountainStarStream);
                        customStarstream2 = new Ring(3f, -4f, 17.9f, 1.4f, 80, resources.StarStreamColors?[2] ?? Calc.HexToColor("30ffff") * 0.5f, resources.MountainStarStreamTexture ?? MTN.MountainStarStream);

                        if (Engine.Scene is Overworld thisOverworld)
                        {
                            thisOverworld.Remove(customMoonParticles);
                            if (resources.StarBeltColors1 != null && resources.StarBeltColors2 != null)
                            {
                                // there are custom moon particle colors. build the new particles and add them to the scene
                                thisOverworld.Remove(vanillaMoonParticles);
                                thisOverworld.Add(customMoonParticles = new patch_MoonParticle3D(this, new Vector3(0f, 31f, 0f), resources.StarBeltColors1, resources.StarBeltColors2));
                            }
                            else
                            {
                                // there are no more moon particle colors. restore the vanilla particles
                                customMoonParticles = null;
                                thisOverworld.Add(vanillaMoonParticles);
                            }
                        }
                    }
                    PreviousSID = SIDToUse;
                    return;
                }
            }

            if (customMoonParticles != null && Engine.Scene is Overworld overworld)
            {
                // revert back the moon particles to vanilla.
                overworld.Remove(customMoonParticles);
                customMoonParticles = null;
                overworld.Add(vanillaMoonParticles);
            }

            orig_BeforeRender(scene);

            Draw.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null);
            Draw.Rect(-10f, -10f, 1940f, 1100f, Color.Black * fade);
            Draw.SpriteBatch.End();

            PreviousSID = SIDToUse;
        }
Exemple #29
0
        private void load()
        {
            const int line_offset   = 80;
            const int circle_offset = 250;

            Children = new Drawable[]
            {
                lines = new Container <Box>
                {
                    Anchor       = Anchor.Centre,
                    Origin       = Anchor.Centre,
                    AutoSizeAxes = Axes.Both,
                    Children     = new[]
                    {
                        lineTopLeft = new Box
                        {
                            Origin   = Anchor.CentreLeft,
                            Anchor   = Anchor.Centre,
                            Position = new Vector2(-line_offset, -line_offset),
                            Rotation = 45,
                            Colour   = Color4.White.Opacity(180),
                        },
                        lineTopRight = new Box
                        {
                            Origin   = Anchor.CentreRight,
                            Anchor   = Anchor.Centre,
                            Position = new Vector2(line_offset, -line_offset),
                            Rotation = -45,
                            Colour   = Color4.White.Opacity(80),
                        },
                        lineBottomLeft = new Box
                        {
                            Origin   = Anchor.CentreLeft,
                            Anchor   = Anchor.Centre,
                            Position = new Vector2(-line_offset, line_offset),
                            Rotation = -45,
                            Colour   = Color4.White.Opacity(230),
                        },
                        lineBottomRight = new Box
                        {
                            Origin   = Anchor.CentreRight,
                            Anchor   = Anchor.Centre,
                            Position = new Vector2(line_offset, line_offset),
                            Rotation = 45,
                            Colour   = Color4.White.Opacity(130),
                        },
                    }
                },
                bigRing     = new Ring(OsuColour.FromHex(@"B6C5E9"), 0.85f),
                mediumRing  = new Ring(Color4.White.Opacity(130), 0.7f),
                smallRing   = new Ring(Color4.White, 0.6f),
                welcomeText = new OsuSpriteText
                {
                    Anchor  = Anchor.Centre,
                    Origin  = Anchor.Centre,
                    Text    = "欢迎",
                    Padding = new MarginPadding {
                        Bottom = 10
                    },
                    Font    = OsuFont.GetFont(weight: FontWeight.Light, size: 120),
                    Alpha   = 0,
                    Spacing = new Vector2(5),
                },
                new CircularContainer
                {
                    Anchor   = Anchor.Centre,
                    Origin   = Anchor.Centre,
                    Size     = new Vector2(logo_size),
                    Masking  = true,
                    Children = new Drawable[]
                    {
                        backgroundFill = new Box
                        {
                            Anchor           = Anchor.Centre,
                            Origin           = Anchor.Centre,
                            RelativeSizeAxes = Axes.Both,
                            Height           = 0,
                            Colour           = OsuColour.FromHex(@"C6D8FF").Opacity(160),
                        },
                        foregroundFill = new Box
                        {
                            Anchor           = Anchor.Centre,
                            Origin           = Anchor.Centre,
                            Size             = Vector2.Zero,
                            RelativeSizeAxes = Axes.Both,
                            Width            = 0,
                            Colour           = Color4.White,
                        },
                    }
                },
                purpleCircle = new Circle
                {
                    Anchor   = Anchor.Centre,
                    Origin   = Anchor.TopCentre,
                    Position = new Vector2(0, circle_offset),
                    Colour   = OsuColour.FromHex(@"AA92FF"),
                },
                blueCircle = new Circle
                {
                    Anchor   = Anchor.Centre,
                    Origin   = Anchor.CentreRight,
                    Position = new Vector2(-circle_offset, 0),
                    Colour   = OsuColour.FromHex(@"8FE5FE"),
                },
                yellowCircle = new Circle
                {
                    Anchor   = Anchor.Centre,
                    Origin   = Anchor.BottomCentre,
                    Position = new Vector2(0, -circle_offset),
                    Colour   = OsuColour.FromHex(@"FFD64C"),
                },
                pinkCircle = new Circle
                {
                    Anchor   = Anchor.Centre,
                    Origin   = Anchor.CentreLeft,
                    Position = new Vector2(circle_offset, 0),
                    Colour   = OsuColour.FromHex(@"e967a1"),
                },
            };

            foreach (var line in lines)
            {
                line.Size  = new Vector2(105, 1.5f);
                line.Alpha = 0;
            }

            Scale = new Vector2(0.5f);
        }
Exemple #30
0
 internal BatRing(Ring pairedRing)
 {
     RingObject = pairedRing;
 }
Exemple #31
0
 internal RaindropRing(Ring pairedRing)
 {
     RingObject = pairedRing;
 }
        internal static List <Item> GetTreasure()
        {
            List <Item> rewards = new List <Item>();

            //Treasure Groups
            List <TreasureGroup> possibleGroups = PanningMod.Instance.treasureGroups.Values
                                                  .Where(group => group.Enabled == true)
                                                  .OrderBy(group => group.GroupChance)
                                                  .ToList();

            // Select rewards
            double chance = 1f;

            while (possibleGroups.Count > 0 && Game1.random.NextDouble() <= chance)
            {
                TreasureGroup group = possibleGroups.ChooseItem(Game1.random);

                // Possible treasure based on selected treasure group selected above.
                List <TreasureData> possibleLoot = new List <TreasureData>(group.treasureList)
                                                   .Where(loot => loot.Enabled)
                                                   .OrderBy(loot => loot.Chance)
                                                   .ThenBy(loot => loot.Id)
                                                   .ToList();

                if (possibleLoot.Count == 0)
                {
                    PanningMod.Instance.Monitor.Log($"   Group: {group.GroupID}, No Possible Loot Found... check the logic");
                    break;
                }

                TreasureData treasure = possibleLoot.ChooseItem(Game1.random);
                int          id       = treasure.Id;

                // Lost books have custom handling
                if (id == 102) // LostBook Item ID
                {
                    if (Game1.player.archaeologyFound == null || !Game1.player.archaeologyFound.ContainsKey(102) || Game1.player.archaeologyFound[102][0] >= 21)
                    {
                        possibleLoot.Remove(treasure);
                        continue;
                    }
                    Game1.showGlobalMessage("You found a lost book. The library has been expanded.");
                }

                // Create reward item
                Item reward;
                if (group.GroupID == TREASURE_GROUP.Rings)
                {
                    reward = new Ring(id);
                }
                else if (group.GroupID == TREASURE_GROUP.Boots)
                {
                    reward = new Boots(id);
                }
                else
                {
                    // Random quantity
                    int count = Game1.random.Next(treasure.MinAmount, treasure.MaxAmount);

                    reward = new StardewValley.Object(id, count);
                }

                // Add the reward
                rewards.Add(reward);

                // Check if this reward shouldn't be duplicated
                if (!treasure.AllowDuplicates)
                {
                    possibleLoot.Remove(treasure);
                }

                // Update chance
                chance *= PanningMod.Instance.config.additionalLootChance + Game1.dailyLuck;
            }

            return(rewards);
        }
Exemple #33
0
 public TransportThread(IoUringOptions options)
 {
     _ring = new Ring(RingSize);
     SetupEventFd();
     _threadContext = new TransportThreadContext(options, _readPollQueue, _writePollQueue, _memoryPool, _eventfd);
 }
Exemple #34
0
        public static IGroupElement CreateRoadSurfaceFromPolygon(IFeature ifeature_0, IFeature3DProperties ifeature3DProperties_0, clsTextureGroup clsTextureGroup_0, ISurface isurface_0, string string_0, IPolygon ipolygon_0, bool bool_0)
        {
            IGroupElement groupElement = null;
            IGroupElement result;

            try
            {
                IEncode3DProperties encode3DProperties = new GeometryEnvironment() as IEncode3DProperties;
                IGroupElement       groupElement2      = new GroupElement() as IGroupElement;
                if (modFacades.m_limitAngle == 0.0)
                {
                    modFacades.m_limitAngle = 0.5235987666666666;
                }
                IGeometry geometry = null;
                if (ifeature_0 != null)
                {
                    if (ifeature3DProperties_0 != null && bool_0)
                    {
                        ifeature3DProperties_0.ApplyFeatureProperties(ifeature_0, out geometry, false);
                        modFacades.g_bFeaturePropertiesApplied = true;
                    }
                    else
                    {
                        geometry = ifeature_0.Shape;
                        modFacades.g_bFeaturePropertiesApplied = false;
                    }
                }
                else if (ipolygon_0 != null)
                {
                    geometry = ipolygon_0;
                }
                if (geometry == null)
                {
                    result = groupElement;
                    return(result);
                }
                if (!(geometry is IMultiPatch))
                {
                }
                IEnvelope envelope = geometry.Envelope;
                double    num      = envelope.ZMin;
                if (modFacades.IsNaN(num))
                {
                    num = 0.0;
                }
                double        num2          = 0.0;
                I3DProperties i3DProperties = ifeature3DProperties_0 as I3DProperties;
                if (i3DProperties.OffsetExpressionString.Length > 0)
                {
                    num2 = Convert.ToDouble(i3DProperties.OffsetExpressionString);
                }
                if (geometry is IPolygon)
                {
                    num += num2;
                }
                IGeometryCollection geometryCollection = geometry as IGeometryCollection;
                int geometryCount = geometryCollection.GeometryCount;
                int num3;
                if (geometry is IMultiPatch)
                {
                    geometryCount = geometryCollection.GeometryCount;
                    num3          = geometryCollection.GeometryCount * 2 / 3;
                    modFacades.m_extrusionHeight = geometry.Envelope.ZMax - geometry.Envelope.ZMin;
                }
                else
                {
                    num3          = 0;
                    geometryCount = geometryCollection.GeometryCount;
                }
                if (modFacades.m_extrusionHeight >= 1.0)
                {
                }
                for (int i = num3; i <= geometryCount - 1; i++)
                {
                    IGeometry        geometry2    = geometryCollection.get_Geometry(i);
                    esriGeometryType geometryType = geometry2.GeometryType;
                    if (geometryType == esriGeometryType.esriGeometryRing || geometryType == esriGeometryType.esriGeometryPolyline)
                    {
                    }
                    IPointCollection pointCollection = geometry2 as IPointCollection;
                    int pointCount = pointCollection.PointCount;
                    if (pointCount >= 2)
                    {
                    }
                    IVector3D vector3D = new Vector3D() as IVector3D;
                    vector3D.XComponent = 0.0;
                    vector3D.YComponent = 0.0;
                    vector3D.ZComponent = 1.0;
                    double m = 0.0;
                    encode3DProperties.PackNormal(vector3D, out m);
                    IPointCollection pointCollection2 = new Ring();
                    object           value            = Missing.Value;
                    short            num4             = 0;
                    while ((int)num4 <= pointCount - 1)
                    {
                        IPoint point = pointCollection.get_Point((int)num4);
                        point.Z = num;
                        point.M = m;
                        IClone clone = point as IClone;
                        pointCollection2.AddPoint(clone.Clone() as IPoint, ref value, ref value);
                        num4 += 1;
                    }
                    IRing ring = pointCollection2 as IRing;
                    ring.Close();
                    IMultiPatch         multiPatch          = new MultiPatch() as IMultiPatch;
                    IGeometryCollection geometryCollection2 = multiPatch as IGeometryCollection;
                    IZAware             iZAware             = multiPatch as IZAware;
                    iZAware.ZAware = true;
                    IMAware iMAware = multiPatch as IMAware;
                    iMAware.MAware = true;
                    geometryCollection2.AddGeometry(pointCollection2 as IGeometry, ref value, ref value);
                    multiPatch.PutRingType(pointCollection2 as IRing, esriMultiPatchRingType.esriMultiPatchOuterRing);
                    IElement element = modFacades.CreateElement(multiPatch, clsTextureGroup_0.RoofSymbol, string_0 + ";ROOFCOLOR=" + clsTextureGroup_0.RoofColorRGB.ToString());
                    if (element != null)
                    {
                        groupElement2.AddElement(element);
                    }
                }
                if (groupElement2 != null)
                {
                    IElementProperties elementProperties = groupElement2 as IElementProperties;
                    elementProperties.Name = string_0;
                }
                groupElement = groupElement2;
                result       = groupElement;
                return(result);
            }
            catch
            {
            }
            result = groupElement;
            return(result);
        }
        public BaseItem GetItemByItemID(int itemID)
        {
            DbParameter itemIdParameter = _db.CreateParameter(DbNames.GETITEMBYITEMID_ITEMID_PARAMETER, itemID);
            itemIdParameter.DbType = DbType.Int32;

            BaseItem b = null;

            _db.Open();

            DbDataReader reader = _db.ExcecuteReader(DbNames.GETITEMBYITEMID_STOREDPROC, CommandType.StoredProcedure, itemIdParameter);

            int ordinalITEM_ITEMID = reader.GetOrdinal(DbNames.ITEM_ITEMID);
            int ordinalITEM_OWNERID = reader.GetOrdinal(DbNames.ITEM_OWNERID);
            int ordinalITEM_REFERENCEID = reader.GetOrdinal(DbNames.ITEM_REFERENCEID);
            int ordinalITEM_BTYPE = reader.GetOrdinal(DbNames.ITEM_BTYPE);
            int ordinalITEM_BKIND = reader.GetOrdinal(DbNames.ITEM_BKIND);
            int ordinalITEM_VISUALID = reader.GetOrdinal(DbNames.ITEM_VISUALID);
            int ordinalITEM_COST = reader.GetOrdinal(DbNames.ITEM_COST);
            int ordinalITEM_CLASS = reader.GetOrdinal(DbNames.ITEM_CLASS);
            int ordinalITEM_AMOUNT = reader.GetOrdinal(DbNames.ITEM_AMOUNT);
            int ordinalITEM_LEVEL = reader.GetOrdinal(DbNames.ITEM_LEVEL);
            int ordinalITEM_DEX = reader.GetOrdinal(DbNames.ITEM_DEX);
            int ordinalITEM_STR = reader.GetOrdinal(DbNames.ITEM_STR);
            int ordinalITEM_STA = reader.GetOrdinal(DbNames.ITEM_STA);
            int ordinalITEM_ENE = reader.GetOrdinal(DbNames.ITEM_ENE);
            int ordinalITEM_MAXIMBUES = reader.GetOrdinal(DbNames.ITEM_MAXIMBUES);
            int ordinalITEM_MAXDURA = reader.GetOrdinal(DbNames.ITEM_MAXDURA);
            int ordinalITEM_CURDURA = reader.GetOrdinal(DbNames.ITEM_CURDURA);
            int ordinalITEM_DAMAGE = reader.GetOrdinal(DbNames.ITEM_DAMAGE);
            int ordinalITEM_DEFENCE = reader.GetOrdinal(DbNames.ITEM_DEFENCE);
            int ordinalITEM_ATTACKRATING = reader.GetOrdinal(DbNames.ITEM_ATTACKRATING);
            int ordinalITEM_ATTACKSPEED = reader.GetOrdinal(DbNames.ITEM_ATTACKSPEED);
            int ordinalITEM_ATTACKRANGE = reader.GetOrdinal(DbNames.ITEM_ATTACKRANGE);
            int ordinalITEM_INCMAXLIFE = reader.GetOrdinal(DbNames.ITEM_INCMAXLIFE);
            int ordinalITEM_INCMAXMANA = reader.GetOrdinal(DbNames.ITEM_INCMAXMANA);
            int ordinalITEM_LIFEREGEN = reader.GetOrdinal(DbNames.ITEM_LIFEREGEN);
            int ordinalITEM_MANAREGEN = reader.GetOrdinal(DbNames.ITEM_MANAREGEN);
            int ordinalITEM_CRITICAL = reader.GetOrdinal(DbNames.ITEM_CRITICAL);
            int ordinalITEM_PLUS = reader.GetOrdinal(DbNames.ITEM_PLUS);
            int ordinalITEM_SLVL = reader.GetOrdinal(DbNames.ITEM_SLVL);
            int ordinalITEM_IMBUETRIES = reader.GetOrdinal(DbNames.ITEM_IMBUETRIES);
            int ordinalITEM_DRAGONSUCCESSIMBUETRIES = reader.GetOrdinal(DbNames.ITEM_DRAGONSUCCESSIMBUETRIES);
            int ordinalITEM_DISCOUNTREPAIRFEE = reader.GetOrdinal(DbNames.ITEM_DISCOUNTREPAIRFEE);
            int ordinalITEM_TOTALDRAGONIMBUES = reader.GetOrdinal(DbNames.ITEM_TOTALDRAGONIMBUES);
            int ordinalITEM_DRAGONDAMAGE = reader.GetOrdinal(DbNames.ITEM_DRAGONDAMAGE);
            int ordinalITEM_DRAGONDEFENCE = reader.GetOrdinal(DbNames.ITEM_DRAGONDEFENCE);
            int ordinalITEM_DRAGONATTACKRATING = reader.GetOrdinal(DbNames.ITEM_DRAGONATTACKRATING);
            int ordinalITEM_DRAGONLIFE = reader.GetOrdinal(DbNames.ITEM_DRAGONLIFE);
            int ordinalITEM_MAPPEDSTUFF = reader.GetOrdinal(DbNames.ITEM_MAPPEDSTUFF);
            int ordinalITEM_FORCENUMBER = reader.GetOrdinal(DbNames.ITEM_FORCENUMBER);
            int ordinalITEM_REBIRTHHOLE = reader.GetOrdinal(DbNames.ITEM_REBIRTHHOLE);
            int ordinalITEM_REBIRTHHOLEITEM = reader.GetOrdinal(DbNames.ITEM_REBIRTHHOLEITEM);
            int ordinalITEM_REBIRTHHOLESTAT = reader.GetOrdinal(DbNames.ITEM_REBIRTHHOLESTAT);
            int ordinalITEM_TOMAPID = reader.GetOrdinal(DbNames.ITEM_TOMAPID);
            int ordinalITEM_IMBUERATE = reader.GetOrdinal(DbNames.ITEM_IMBUERATE);
            int ordinalITEM_IMBUEINCREASE = reader.GetOrdinal(DbNames.ITEM_IMBUEINCREASE);
            int ordinalITEM_BOOKSKILLID = reader.GetOrdinal(DbNames.ITEM_BOOKSKILLID);
            int ordinalITEM_BOOKSKILLLEVEL = reader.GetOrdinal(DbNames.ITEM_BOOKSKILLLEVEL);
            int ordinalITEM_BOOKSKILLDATA = reader.GetOrdinal(DbNames.ITEM_BOOKSKILLDATA);
            int ordinalITEM_MAXPOLISHTRIES = reader.GetOrdinal(DbNames.ITEM_MAXPOLISHTRIES);
            int ordinalITEM_POLISHTRIES = reader.GetOrdinal(DbNames.ITEM_POLISHTRIES);
            int ordinalITEM_VIGISTAT1 = reader.GetOrdinal(DbNames.ITEM_VIGISTAT1);
            int ordinalITEM_VIGISTAT2 = reader.GetOrdinal(DbNames.ITEM_VIGISTAT2);
            int ordinalITEM_VIGISTAT3 = reader.GetOrdinal(DbNames.ITEM_VIGISTAT3);
            int ordinalITEM_VIGISTAT4 = reader.GetOrdinal(DbNames.ITEM_VIGISTAT4);
            int ordinalITEM_VIGISTATADD1 = reader.GetOrdinal(DbNames.ITEM_VIGISTATADD1);
            int ordinalITEM_VIGISTATADD2 = reader.GetOrdinal(DbNames.ITEM_VIGISTATADD2);
            int ordinalITEM_VIGISTATADD3 = reader.GetOrdinal(DbNames.ITEM_VIGISTATADD3);
            int ordinalITEM_VIGISTATADD4 = reader.GetOrdinal(DbNames.ITEM_VIGISTATADD4);
            int ordinalITEM_BAG = reader.GetOrdinal(DbNames.ITEM_BAG);
            int ordinalITEM_SLOT = reader.GetOrdinal(DbNames.ITEM_SLOT);
            int ordinalITEM_SIZEX = reader.GetOrdinal(DbNames.ITEM_SIZEX);
            int ordinalITEM_SIZEY = reader.GetOrdinal(DbNames.ITEM_SIZEY);

            while (reader.Read())
            {
                int BType = reader.GetByte(ordinalITEM_BTYPE);
                int BKind = reader.GetByte(ordinalITEM_BKIND);

                if (BType == (byte)bType.Weapon || BType == (byte)bType.Clothes || BType == (byte)bType.Hat || BType == (byte)bType.Necklace
                    || BType == (byte)bType.Ring || BType == (byte)bType.Shoes || BType == (byte)bType.Cape)
                {
                    if (BKind == (byte)bKindWeapons.Sword && BType == (byte)bType.Weapon)
                    {
                        b = new Sword();
                    }
                    if (BKind == (byte)bKindWeapons.Blade && BType == (byte)bType.Weapon)
                    {
                        b = new Blade();
                    }
                    if (BKind == (byte)bKindWeapons.Fan && BType == (byte)bType.Weapon)
                    {
                        b = new Fan();
                    }
                    if (BKind == (byte)bKindWeapons.Brush && BType == (byte)bType.Weapon)
                    {
                        b = new Brush();
                    }
                    if (BKind == (byte)bKindWeapons.Claw && BType == (byte)bType.Weapon)
                    {
                        b = new Claw();
                    }
                    if (BKind == (byte)bKindWeapons.Axe && BType == (byte)bType.Weapon)
                    {
                        b = new Axe();
                    }
                    if (BKind == (byte)bKindWeapons.Talon && BType == (byte)bType.Weapon)
                    {
                        b = new Talon();
                    }
                    if (BKind == (byte)bKindWeapons.Tonfa && BType == (byte)bType.Weapon)
                    {
                        b = new Tonfa();
                    }
                    if (BKind == (byte)bKindArmors.SwordMan && BType == (byte)bType.Clothes)
                    {
                        b = new Clothes();
                    }
                    if (BKind == (byte)bKindArmors.Mage && BType == (byte)bType.Clothes)
                    {
                        b = new Dress();
                    }
                    if (BKind == (byte)bKindArmors.Warrior && BType == (byte)bType.Clothes)
                    {
                        b = new Armor();
                    }
                    if (BKind == (byte)bKindArmors.GhostFighter && BType == (byte)bType.Clothes)
                    {
                        b = new LeatherClothes();
                    }
                    if (BKind == (byte)bKindHats.SwordMan && BType == (byte)bType.Hat)
                    {
                        b = new Hood();
                    }
                    if (BKind == (byte)bKindHats.Mage && BType == (byte)bType.Hat)
                    {
                        b = new Tiara();
                    }
                    if (BKind == (byte)bKindHats.Warrior && BType == (byte)bType.Hat)
                    {
                        b = new Helmet();
                    }
                    if (BKind == (byte)bKindHats.GhostFighter && BType == (byte)bType.Hat)
                    {
                        b = new Hat();
                    }
                    if (BKind == (byte)bKindHats.SwordMan && BType == (byte)bType.Shoes)
                    {
                        b = new SmBoots();
                    }
                    if (BKind == (byte)bKindHats.Mage && BType == (byte)bType.Shoes)
                    {
                        b = new MageBoots();
                    }
                    if (BKind == (byte)bKindHats.Warrior && BType == (byte)bType.Shoes)
                    {
                        b = new WarriorShoes();
                    }
                    if (BKind == (byte)bKindHats.GhostFighter && BType == (byte)bType.Shoes)
                    {
                        b = new GhostFighterShoes();
                    }
                    if (BKind == 0 && BType == (byte)bType.Ring)
                    {
                        b = new Ring();
                    }
                    if (BKind == 0 && BType == (byte)bType.Necklace)
                    {
                        b = new Necklace();
                    }
                    if (BType == (byte)bType.Cape)
                    {
                        b = new Cape();
                        Cape c = b as Cape;
                        c.MaxPolishImbueTries = reader.GetInt16(ordinalITEM_MAXPOLISHTRIES);
                        c.PolishImbueTries = reader.GetByte(ordinalITEM_POLISHTRIES);
                        c.VigiStat1 = reader.GetInt16(ordinalITEM_VIGISTAT1);
                        c.VigiStatAdd1 = reader.GetInt16(ordinalITEM_VIGISTATADD1);
                        c.VigiStat2 = reader.GetInt16(ordinalITEM_VIGISTAT2);
                        c.VigiStatAdd2 = reader.GetInt16(ordinalITEM_VIGISTATADD2);
                        c.VigiStat3 = reader.GetInt16(ordinalITEM_VIGISTAT3);
                        c.VigiStatAdd3 = reader.GetInt16(ordinalITEM_VIGISTATADD3);
                        c.VigiStat4 = reader.GetInt16(ordinalITEM_VIGISTAT4);
                        c.VigiStatAdd4 = reader.GetInt16(ordinalITEM_VIGISTATADD4);
                    }

                    Equipment e = b as Equipment;
                    e.RequiredLevel = reader.GetInt16(ordinalITEM_LEVEL);
                    e.RequiredDexterity = reader.GetInt16(ordinalITEM_DEX);
                    e.RequiredStrength = reader.GetInt16(ordinalITEM_STR);
                    e.RequiredStamina = reader.GetInt16(ordinalITEM_STA);
                    e.RequiredEnergy = reader.GetInt16(ordinalITEM_ENE);
                    e.MaxImbueTries = reader.GetByte(ordinalITEM_MAXIMBUES);
                    e.Durability = reader.GetInt16(ordinalITEM_CURDURA);
                    e.MaxDurability = reader.GetInt16(ordinalITEM_MAXDURA);
                    e.Damage = reader.GetInt16(ordinalITEM_DAMAGE);
                    e.Defence = reader.GetInt16(ordinalITEM_DEFENCE);
                    e.AttackRating = reader.GetInt16(ordinalITEM_ATTACKRATING);
                    e.AttackSpeed = reader.GetInt16(ordinalITEM_ATTACKSPEED);
                    e.AttackRange = reader.GetInt16(ordinalITEM_ATTACKRANGE);
                    e.IncMaxLife = reader.GetInt16(ordinalITEM_INCMAXLIFE);
                    e.IncMaxMana = reader.GetInt16(ordinalITEM_INCMAXMANA);
                    e.IncLifeRegen = reader.GetInt16(ordinalITEM_LIFEREGEN);
                    e.IncManaRegen = reader.GetInt16(ordinalITEM_MANAREGEN);
                    e.Critical = reader.GetInt16(ordinalITEM_CRITICAL);
                    e.Plus = reader.GetByte(ordinalITEM_PLUS);
                    e.Slvl = reader.GetByte(ordinalITEM_SLVL);
                    e.ImbueTries = reader.GetByte(ordinalITEM_IMBUETRIES);
                    e.DragonSuccessImbueTries = reader.GetInt16(ordinalITEM_DRAGONSUCCESSIMBUETRIES);
                    e.DiscountRepairFee = reader.GetByte(ordinalITEM_DISCOUNTREPAIRFEE);
                    e.TotalDragonImbueTries = reader.GetInt16(ordinalITEM_TOTALDRAGONIMBUES);
                    e.DragonDamage = reader.GetInt16(ordinalITEM_DRAGONDAMAGE);
                    e.DragonDefence = reader.GetInt16(ordinalITEM_DRAGONDEFENCE);
                    e.DragonAttackRating = reader.GetInt16(ordinalITEM_DRAGONATTACKRATING);
                    e.DragonLife = reader.GetInt16(ordinalITEM_DRAGONLIFE);
                    e.MappedData = reader.GetByte(ordinalITEM_MAPPEDSTUFF);
                    e.ForceSlot = reader.GetByte(ordinalITEM_FORCENUMBER);
                    e.RebirthHole = reader.GetByte(ordinalITEM_REBIRTHHOLE);
                    e.RebirthHoleItem = reader.GetByte(ordinalITEM_REBIRTHHOLEITEM);
                    e.RebirthHoleStat = reader.GetInt16(ordinalITEM_REBIRTHHOLESTAT);
                }

                if (BType == (byte)bType.ImbueItem)
                {
                    if (BKind == (byte)bKindStones.Black)
                    {
                        b = new Black();
                    }
                    if (BKind == (byte)bKindStones.White)
                    {
                        b = new White();
                    }
                    if (BKind == (byte)bKindStones.Red)
                    {
                        b = new Red();
                    }
                    if (BKind == (byte)bKindStones.Dragon)
                    {
                        b = new Dragon();
                    }

                    ImbueItem im = b as ImbueItem;
                    im.ImbueChance = reader.GetInt16(ordinalITEM_IMBUERATE);
                    im.IncreaseValue = reader.GetInt16(ordinalITEM_IMBUEINCREASE);
                }

                if (BType == (byte)bType.Potion)
                {
                    if (BKind == (byte)bKindPotions.Normal)
                    {
                        b = new Potion();
                    }
                    if (BKind == (byte)bKindPotions.Elixir)
                    {
                        b = new Elixir();
                    }

                    PotionItem pot = b as PotionItem;
                    pot.HealHp = reader.GetInt16(ordinalITEM_INCMAXLIFE);
                    pot.HealMana = reader.GetInt16(ordinalITEM_INCMAXMANA);
                }
                if (BType == (byte)bType.Book)
                {
                    if (BKind == (byte)bKindBooks.SoftBook)
                    {
                        b = new SoftBook();
                    }
                    if (BKind == (byte)bKindBooks.HardBook)
                    {
                        b = new HardBook();
                    }

                    BookItem book = b as BookItem;
                    book.RequiredClass = reader.GetByte(ordinalITEM_CLASS);
                    book.RequiredLevel = reader.GetInt16(ordinalITEM_LEVEL);
                    book.SkillID = reader.GetInt32(ordinalITEM_BOOKSKILLID);
                    book.SkillLevel = reader.GetByte(ordinalITEM_BOOKSKILLLEVEL);
                    book.SkillData = reader.GetInt32(ordinalITEM_BOOKSKILLDATA);
                }
                if (BType == (byte)bType.Bead)
                {
                    if (BKind == (byte)bKindBeads.Normal)
                    {
                        b = new Bead();
                    }
                    BeadItem bead = b as BeadItem;
                    bead.ToMapID = reader.GetInt32(ordinalITEM_TOMAPID);
                }

                b.ItemID = reader.GetInt32(ordinalITEM_ITEMID);
                b.OwnerID = reader.GetInt32(ordinalITEM_OWNERID);
                b.ReferenceID = reader.GetInt16(ordinalITEM_REFERENCEID);
                b.VisualID = reader.GetInt16(ordinalITEM_VISUALID);
                b.Bag = reader.GetByte(ordinalITEM_BAG);
                b.Slot = reader.GetByte(ordinalITEM_SLOT);
                b.bType = reader.GetByte(ordinalITEM_BTYPE);
                b.bKind = reader.GetByte(ordinalITEM_BKIND);
                b.RequiredClass = reader.GetByte(ordinalITEM_CLASS);
                b.Amount = reader.GetInt16(ordinalITEM_AMOUNT);
                b.SizeX = reader.GetByte(ordinalITEM_SIZEX);
                b.SizeY = reader.GetByte(ordinalITEM_SIZEY);
                b.Price = reader.GetInt32(ordinalITEM_COST);
            }

            reader.Close();
            _db.Close();

            return b;
        }
Exemple #36
0
        public void RingsOnTick(UpdateTickedEventArgs e)
        {
            /* Ring behaviours */

            Ring ring;

            if (Game1.player.canMove)
            {
                ring = HasRingEquipped((int)eID.hotironRing);
                if (ring != null)
                {
                    // Hot Iron Ring
                    HotIronOnTick(ring.uniqueID.Value);
                    if (e.IsOneSecond)
                    {
                        HotIronPerSecond();
                    }
                }

                // Spiteful Ring
                SpitefulOnTick();

                // Wretched Ring
                WretchedOnTick();

                // Heart Ring
                if (HasRingEquipped((int)eID.heartRing) != null)
                {
                    if (playerLeftRingLastTick.indexInTileSheet.Value != (int)eID.heartRing &&
                        playerRightRingLastTick.indexInTileSheet.Value != (int)eID.heartRing)
                    {
                        HeartEquipped();
                    }
                }
            }

            // Ring of Redemption
            if (redemptionActive)
            {
                if (e.IsMultipleOf(3))
                {
                    Game1.player.health = Math.Min(Game1.player.health + 2, Game1.player.maxHealth);
                }
            }

            /* Player changed location */

            if (Game1.currentLocation != playerLocationLastTick)
            {
                // Perform unequip behaviours
                if (Game1.player.leftRing.Value != null)
                {
                    RingUnequipped(Game1.player.leftRing.Value);
                }
                if (Game1.player.rightRing.Value != null)
                {
                    RingUnequipped(Game1.player.rightRing.Value);
                }
            }

            /* Player changed rings */

            // Unequip previous ring
            if (Game1.player.leftRing.Value != playerLeftRingLastTick && playerLeftRingLastTick != null)
            {
                RingUnequipped(playerLeftRingLastTick);
            }
            if (Game1.player.rightRing.Value != playerRightRingLastTick && playerRightRingLastTick != null)
            {
                RingUnequipped(playerRightRingLastTick);
            }

            /* Player changed health */

            // Health was reduced
            if (playerHealthLastTick > Game1.player.health)
            {
                PlayerTakenDamage(playerHealthLastTick - Game1.player.health);
            }

            /* Update mod spectator values */

            // Update player health from last tick
            playerHealthLastTick = Game1.player.health;

            // Update player location from last tick
            playerLocationLastTick = Game1.player.currentLocation;

            // Update player rings from last tick
            playerLeftRingLastTick  = Game1.player.leftRing.Value;
            playerRightRingLastTick = Game1.player.rightRing.Value;
        }
Exemple #37
0
        public static Item getItem(string type, int index = -1, string name = "none")
        {
            Item item = null;

            if (type == "Object")
            {
                if (index != -1)
                {
                    item = new StardewValley.Object(index, 1);
                }
                else if (name != "none")
                {
                    item = new StardewValley.Object(Game1.objectInformation.getIndexByName(name), 1);
                }
            }
            else if (type == "BigObject")
            {
                if (index != -1)
                {
                    item = new StardewValley.Object(Vector2.Zero, index);
                }
                else if (name != "none")
                {
                    item = new StardewValley.Object(Vector2.Zero, Game1.bigCraftablesInformation.getIndexByName(name));
                }
            }
            else if (type == "Ring")
            {
                if (index != -1)
                {
                    item = new Ring(index);
                }
                else if (name != "none")
                {
                    item = new Ring(Game1.objectInformation.getIndexByName(name));
                }
            }
            else if (type == "Hat")
            {
                if (index != -1)
                {
                    item = new Hat(index);
                }
                else if (name != "none")
                {
                    item = new Hat(TMXLoaderMod.helper.Content.Load <Dictionary <int, string> >(@"Data/hats", ContentSource.GameContent).getIndexByName(name));
                }
            }
            else if (type == "Boots")
            {
                if (index != -1)
                {
                    item = new Boots(index);
                }
                else if (name != "none")
                {
                    item = new Boots(TMXLoaderMod.helper.Content.Load <Dictionary <int, string> >(@"Data/Boots", ContentSource.GameContent).getIndexByName(name));
                }
            }
            else if (type == "Clothing")
            {
                if (index != -1)
                {
                    item = new Clothing(index);
                }
                else if (name != "none")
                {
                    item = new Clothing(TMXLoaderMod.helper.Content.Load <Dictionary <int, string> >(@"Data/ClothingInformation", ContentSource.GameContent).getIndexByName(name));
                }
            }
            else if (type == "TV")
            {
                if (index != -1)
                {
                    item = new StardewValley.Objects.TV(index, Vector2.Zero);
                }
                else if (name != "none")
                {
                    item = new TV(TMXLoaderMod.helper.Content.Load <Dictionary <int, string> >(@"Data/Furniture", ContentSource.GameContent).getIndexByName(name), Vector2.Zero);
                }
            }
            else if (type == "IndoorPot")
            {
                item = new StardewValley.Objects.IndoorPot(Vector2.Zero);
            }
            else if (type == "CrabPot")
            {
                item = new StardewValley.Objects.CrabPot(Vector2.Zero);
            }
            else if (type == "Chest")
            {
                item = new StardewValley.Objects.Chest(true);
            }
            else if (type == "Cask")
            {
                item = new StardewValley.Objects.Cask(Vector2.Zero);
            }
            else if (type == "Cask")
            {
                item = new StardewValley.Objects.Cask(Vector2.Zero);
            }
            else if (type == "Furniture")
            {
                if (index != -1)
                {
                    item = new StardewValley.Objects.Furniture(index, Vector2.Zero);
                }
                else if (name != "none")
                {
                    item = new Furniture(TMXLoaderMod.helper.Content.Load <Dictionary <int, string> >(@"Data/Furniture", ContentSource.GameContent).getIndexByName(name), Vector2.Zero);
                }
            }
            else if (type == "Sign")
            {
                item = new StardewValley.Objects.Sign(Vector2.Zero, index);
            }
            else if (type == "Wallpaper")
            {
                item = new StardewValley.Objects.Wallpaper(Math.Abs(index), false);
            }
            else if (type == "Floors")
            {
                item = new StardewValley.Objects.Wallpaper(Math.Abs(index), true);
            }
            else if (type == "MeleeWeapon")
            {
                if (index != -1)
                {
                    item = new MeleeWeapon(index);
                }
                else if (name != "none")
                {
                    item = new MeleeWeapon(TMXLoaderMod.helper.Content.Load <Dictionary <int, string> >(@"Data/weapons", ContentSource.GameContent).getIndexByName(name));
                }
            }
            else if (type == "CustomObject" && PyTK.CustomElementHandler.CustomObjectData.collection.ContainsKey(name))
            {
                item = PyTK.CustomElementHandler.CustomObjectData.collection[name].getObject();
            }
            else if (type == "SDVType")
            {
                try
                {
                    if (index == -1)
                    {
                        item = Activator.CreateInstance(PyUtils.getTypeSDV(name)) is Item i ? i : null;
                    }
                    else
                    {
                        item = Activator.CreateInstance(PyUtils.getTypeSDV(name), index) is Item i ? i : null;
                    }
                }
                catch (Exception ex)
                {
                    TMXLoaderMod.monitor.Log(ex.Message + ":" + ex.StackTrace, LogLevel.Error);
                    TMXLoaderMod.monitor.Log("Couldn't load item SDVType: " + name);
                }
            }
            else if (type == "ByType")
            {
                try
                {
                    if (index == -1)
                    {
                        item = Activator.CreateInstance(Type.GetType(name)) is Item i ? i : null;
                    }
                    else
                    {
                        item = Activator.CreateInstance(Type.GetType(name), index) is Item i ? i : null;
                    }
                }
                catch (Exception ex)
                {
                    TMXLoaderMod.monitor.Log(ex.Message + ":" + ex.StackTrace, LogLevel.Error);
                    TMXLoaderMod.monitor.Log("Couldn't load item ByType: " + name);
                }
            }

            return(item);
        }
Exemple #38
0
        public Item UnpackItem(ModDataDictionary modData, string recipientName)
        {
            string[] fields = new[] {
                "giftsender", "giftname", "giftid",
                "giftparentid", "gifttype", "giftstack",
                "giftquality", "giftpreserve", "gifthoney",
                "giftcolour", "giftdata"
            };
            if (fields.Any(field => !modData.ContainsKey(AssetPrefix + field)))
            {
                string msg = fields.Where(field => !modData.ContainsKey(field))
                             .Aggregate("This gift is missing data:", (str, field) => str + "\n" + field)
                             + "\nIf this gift was placed before updating, please revert to the previous version and collect the gift!"
                             + "\nOtherwise, leave a report on the mod page for Gift Wrapper with your log file (https://smapi.io/log).";
                Monitor.Log(msg, LogLevel.Warn);
                return(null);
            }

            // Parse the wrapped gift's serialised modData fields to use in rebuilding its gift item
            long   giftSender   = long.Parse(modData[AssetPrefix + fields[0]]);
            string giftName     = modData[AssetPrefix + fields[1]];
            int    giftId       = int.Parse(modData[AssetPrefix + fields[2]]);
            int    giftParentId = int.Parse(modData[AssetPrefix + fields[3]]);
            int    giftType     = int.Parse(modData[AssetPrefix + fields[4]]);
            int    giftStack    = int.Parse(modData[AssetPrefix + fields[5]]);
            int    giftQuality  = int.Parse(modData[AssetPrefix + fields[6]]);
            int    giftPreserve = int.Parse(modData[AssetPrefix + fields[7]]);
            int    giftHoney    = int.Parse(modData[AssetPrefix + fields[8]]);
            string giftColour   = modData[AssetPrefix + fields[9]];
            string giftData     = modData[AssetPrefix + fields[10]];
            Item   actualGift   = null;

            switch (giftType)
            {
            case (int)GiftType.BedFurniture:
                actualGift = new BedFurniture(which: giftId, tile: Vector2.Zero);
                break;

            case (int)GiftType.Furniture:
                actualGift = new Furniture(which: giftId, tile: Vector2.Zero);
                break;

            case (int)GiftType.BigCraftable:
                actualGift = new StardewValley.Object(tileLocation: Vector2.Zero, parentSheetIndex: giftId, isRecipe: false);
                break;

            case (int)GiftType.MeleeWeapon:
                actualGift = new MeleeWeapon(spriteIndex: giftId);
                break;

            case (int)GiftType.Hat:
                actualGift = new Hat(which: giftId);
                break;

            case (int)GiftType.Boots:
                actualGift = new Boots(which: giftId);                         // todo: test boots colour
                ((Boots)actualGift).appliedBootSheetIndex.Set(giftQuality);
                ((Boots)actualGift).indexInColorSheet.Set(int.Parse(giftColour));
                break;

            case (int)GiftType.Clothing:
                int[] colourSplit = giftColour.Split('/').ToList().ConvertAll(int.Parse).ToArray();
                Color colour      = new Color(r: colourSplit[0], g: colourSplit[1], b: colourSplit[2], a: colourSplit[3]);
                actualGift = new Clothing(item_index: giftId);
                ((Clothing)actualGift).clothesColor.Set(colour);
                break;

            case (int)GiftType.Ring:
                actualGift = new Ring(which: giftId);
                break;

            case (int)GiftType.Object:
                actualGift = new StardewValley.Object(parentSheetIndex: giftId, initialStack: giftStack)
                {
                    Quality = giftQuality
                };
                actualGift.Name = giftName;
                if (giftParentId != -1)
                {
                    ((StardewValley.Object)actualGift).preservedParentSheetIndex.Value = giftParentId;
                }
                if (giftPreserve != -1)
                {
                    ((StardewValley.Object)actualGift).preserve.Value = (StardewValley.Object.PreserveType)giftPreserve;
                }
                if (giftHoney != 0)
                {
                    ((StardewValley.Object)actualGift).honeyType.Value = (StardewValley.Object.HoneyType)giftHoney;
                }
                break;
            }

            if (actualGift == null)
            {
                return(null);
            }

            Dictionary <string, string> giftDataDeserialised = ((Newtonsoft.Json.Linq.JObject)JsonConvert.DeserializeObject(giftData)).ToObject <Dictionary <string, string> >();

            if (giftDataDeserialised != null)
            {
                // Apply serialised mod data back to the gifted item
                actualGift.modData.Set(giftDataDeserialised);
            }

            if (recipientName != null && Game1.player.UniqueMultiplayerID != giftSender)
            {
                // Show a message to all players to celebrate this wonderful event
                Multiplayer multiplayer = Helper.Reflection.GetField <Multiplayer>(typeof(Game1), "multiplayer").GetValue();
                multiplayer.globalChatInfoMessage(AssetPrefix + (giftStack > 1 ? "message.giftopened_quantity" : "message.giftopened"),
                                                  recipientName,                    // Recipient's name
                                                  Game1.getFarmer(giftSender).Name, // Sender's name
                                                  actualGift.DisplayName,           // Gift name
                                                  giftStack.ToString());            // Gift quantity
            }

            return(actualGift);
        }
Exemple #39
0
        static void Main(string[] args)
        {
            Test17();
            return;

            Console.WriteLine("_________________TEST 0__________________________");
            Test0();
            Console.WriteLine("_________________TEST 1__________________________");
            Test1();
            Console.WriteLine("_________________TEST 3__________________________");
            Test3();
            Console.WriteLine("_________________TEST 4__________________________");
            Test4();
            return;

            Ring r = new Ring(Field.Real, new string[] { "x", "y", "z" });

            r.FixOrder(new string[] { "x", "y", "z" });

            Polynomial f1 = new Polynomial(r);

            f1.AddTerm(1, new int[] { 0, 1, 2 });
            f1.AddTerm(1, new int[] { 0, 0, 2 });

            Polynomial f2 = new Polynomial(r);

            f2.AddTerm(1, new int[] { 3, 1, 0 });
            f2.AddTerm(1, new int[] { 1, 0, 0 });
            f2.AddTerm(1, new int[] { 0, 1, 0 });
            f2.AddTerm(1, new int[] { 0, 0, 0 });

            Polynomial f3 = new Polynomial(r);

            f3.AddTerm(1, new int[] { 0, 0, 1 });
            f3.AddTerm(1, new int[] { 2, 0, 0 });
            f3.AddTerm(1, new int[] { 0, 3, 0 });

            Ideal I = new Ideal(new Polynomial[] { f1, f2, f3 }, r);


            Console.WriteLine("__________Gröbner Basis__________________");
            var gb = I.GröbnerBasis();

            foreach (var p in gb)
            {
                Console.WriteLine(p);
            }

            Console.WriteLine("_________Minimal Gröbner Basis___________________");

            var minimal = I.MinimalGröbnerBasis();

            foreach (var p in minimal)
            {
                Console.WriteLine(p);
            }

            Console.WriteLine("______________Reduced Gröbner Basis______________");


            var reduced = I.ReducedGrobnerBasis();

            foreach (var p in reduced)
            {
                Console.WriteLine(p);
            }

            Console.WriteLine("__________Membership__________________");
            Console.WriteLine(I.Member(f1));
            Console.Read();
        }
    private void Generate()
    {
        int total = 0;

        //Instantiate Parent object
        GameObject p = new GameObject();

        //Set parent properties
        p.gameObject.transform.position   = parent.transform.position;
        p.gameObject.transform.rotation   = parent.transform.rotation;
        p.gameObject.transform.localScale = parent.transform.localScale;
        p.gameObject.name     = "Audio Visualizer";
        audioVisualizerParent = p;
        if (addAnimationRecorder)
        {
            p.AddComponent <UnityAnimationRecorder>();
        }

        //Initialize Rings
        rings = new Ring[ringState == RingState.Single ? 1 : numberOfRings];

        for (int i = 0; i < rings.Length; i++)
        {
            //Create new Ring
            rings[i] = new Ring
            {
                parent = new GameObject(),
                cubes  = new GameObject[
                    ringState == RingState.Single
                        ? Convert.ToInt32(Mathf.PI * radius * xScale)
                        : Convert.ToInt32(Mathf.PI * (maxRadius - ((maxRadius - minRadius) * Convert.ToSingle(Mathf.Log(1f + (i) / (numberOfRings - 1f), 2)))) * xScale)
                         ]
            };
            //Set Ring Property
            rings[i].parent.transform.parent = p.transform;
            rings[i].parent.gameObject.name  = "Ring " + i;
            //Initialize the cubes in the ring
            for (int j = 0; j < rings[i].cubes.Length; j++)
            {
                //Calculate the location that the cube will
                float   angle = j * Mathf.PI * 2 / rings[i].cubes.Length;
                Vector3 pos   = new Vector3(Mathf.Cos(angle), 0, Mathf.Sin(angle))
                                * (ringState == RingState.Single
                      ? radius
                      : (maxRadius - ((maxRadius - minRadius) * Convert.ToSingle(Mathf.Log(1f + (i) / (numberOfRings - 1f), 2))))
                                   );

                //Instantiate cube from prefab
                GameObject tmp = Instantiate(prefab, pos, Quaternion.identity);

                //Set cube properties
                tmp.transform.parent = rings[i].parent.transform;
                tmp.gameObject.name  = "Ring " + i + " Cube " + j;

                //Set cube y scale
                Vector3 prevScale = tmp.transform.localScale;
                prevScale.y = 0.01f;
                tmp.transform.localScale = prevScale;

                //Add color change component
                tmp.AddComponent <ColorChange>();
                UpdateColor(tmp.GetComponent <ColorChange>());

                //Add to list
                rings[i].cubes[j] = tmp;
            }
            total += rings[i].cubes.Length;
        }
        Debug.Log(rings.Length + " rings generated. " + total + " cubes generated. ");
    }
Exemple #41
0
        public static Polygon ParseMultiPolygon(string wkt)
        {
            wkt = wkt.ToUpper();

            if (!wkt.StartsWith("MULTIPOLYGON"))
            {
                throw new ArgumentException("Invalid WKT: must start with 'MULTIPOLYGON'", "wkt");
            }

            // chop off front and end
            // then split by polygon
            int idx = wkt.IndexOf('(');
            string[] polywkts = wkt.Substring(idx+1, wkt.Length-idx-1).Split(new string[] {")),((", ")), (("}, StringSplitOptions.None);

            Polygon p = new Polygon();

            foreach (string polywkt in polywkts)
            {
                // split by ring
                string[] ringwkts = polywkt.Split(new string[] {"),(", "), ("}, StringSplitOptions.None);

                for (int ii=0; ii<ringwkts.Length; ii++)
                {
                    // trim off parens
                    string ringwkt =  ringwkts[ii].Trim(new char[] {'(',')'});

                    Ring r = new Ring();

                    // split by coordinate
                    string[] coords = ringwkt.Split(',');

                    foreach (string coord in coords)
                    {
                        r.Points.Add(SplitPoint(coord));
                    }

                    if (!r.IsClosed) r.Close();

                    p.Rings.Add(r);
                }
            }

            return p;
        }
        //Public Methods:
        public void Update()
        {
            //update keypoints and fingers:
            WristCenter.Update(_managedHand, _managedHand.Hand.Wrist.Center.Position, _managedHand.Hand.Center);
            HandCenter.Update(_managedHand, _managedHand.Hand.Center);
            _thumbMCP.Update(_managedHand, _managedHand.Hand.Thumb.MCP.Position, _managedHand.Hand.Index.MCP.Position, _managedHand.Hand.Center);
            _thumbPIP.Update(_managedHand, _managedHand.Hand.Thumb.IP.Position, _managedHand.Hand.Thumb.MCP.Position, _managedHand.Hand.Center);
            _thumbTip.Update(_managedHand, _managedHand.Hand.Thumb.Tip.Position, _managedHand.Hand.Thumb.IP.Position, _managedHand.Hand.Middle.Tip.Position, _managedHand.Hand.Thumb.MCP.Position, _managedHand.Hand.Center);
            Thumb.Update();
            _indexMCP.Update(_managedHand, _managedHand.Hand.Index.MCP.Position, _managedHand.Hand.Center);
            _indexPIP.Update(_managedHand, _managedHand.Hand.Index.PIP.Position, _managedHand.Hand.Index.MCP.Position, _managedHand.Hand.Center);
            _indexTip.Update(_managedHand, _managedHand.Hand.Index.Tip.Position, _managedHand.Hand.Index.PIP.Position, _managedHand.Hand.Index.MCP.Position, _managedHand.Hand.Center, _managedHand.Hand.Thumb.IP.Position, _managedHand.Hand.Middle.Tip.Position);
            Index.Update();
            _middleMCP.Update(_managedHand, _managedHand.Hand.Middle.MCP.Position, _managedHand.Hand.Center);
            _middlePIP.Update(_managedHand, _managedHand.Hand.Middle.PIP.Position, _managedHand.Hand.Middle.MCP.Position, _managedHand.Hand.Center);
            _middleTip.Update(_managedHand, _managedHand.Hand.Middle.Tip.Position, _managedHand.Hand.Middle.PIP.Position, _managedHand.Hand.Middle.MCP.Position, _managedHand.Hand.Ring.Tip.Position, _managedHand.Hand.Center);
            Middle.Update();
            _ringMCP.Update(_managedHand, _managedHand.Hand.Ring.MCP.Position, _managedHand.Hand.Center);
            _ringTip.Update(_managedHand, _managedHand.Hand.Ring.Tip.Position, _managedHand.Hand.Ring.MCP.Position, _managedHand.Hand.Pinky.Tip.Position, _managedHand.Hand.Middle.Tip.Position, _managedHand.Hand.Center);
            Ring.Update();
            _pinkyMCP.Update(_managedHand, _managedHand.Hand.Pinky.MCP.Position, _managedHand.Hand.Center);
            _pinkyTip.Update(_managedHand, _managedHand.Hand.Pinky.Tip.Position, _managedHand.Hand.Pinky.MCP.Position, _managedHand.Hand.Ring.Tip.Position, _managedHand.Hand.Center);
            Pinky.Update();

            //we need a hand to continue:
            if (!_managedHand.Visible)
            {
                return;
            }

            //correct distances:
            float thumbMcpToWristDistance = Vector3.Distance(_thumbMCP.positionFiltered, WristCenter.positionFiltered) * .5f;
            //fix the distance between the wrist and thumbMcp as it incorrectly expands as the hand gets further from the camera:
            float distancePercentage = Mathf.Clamp01(Vector3.Distance(_mainCamera.transform.position, WristCenter.positionFiltered) / .5f);

            distancePercentage       = 1 - Percentage(distancePercentage, .90f, 1) * .4f;
            thumbMcpToWristDistance *= distancePercentage;
            Vector3 wristToPalmDirection = Vector3.Normalize(Vector3.Normalize(HandCenter.positionFiltered - WristCenter.positionFiltered));
            Vector3 center = WristCenter.positionFiltered + (wristToPalmDirection * thumbMcpToWristDistance);
            Vector3 camToWristDirection = Vector3.Normalize(WristCenter.positionFiltered - _mainCamera.transform.position);

            //rays needed for planarity discovery for in/out palm facing direction:
            Vector3 camToWrist    = new Ray(WristCenter.positionFiltered, camToWristDirection).GetPoint(1);
            Vector3 camToThumbMcp = new Ray(_thumbMCP.positionFiltered, Vector3.Normalize(_thumbMCP.positionFiltered - _mainCamera.transform.position)).GetPoint(1);
            Vector3 camToPalm     = new Ray(center, Vector3.Normalize(center - _mainCamera.transform.position)).GetPoint(1);

            //discover palm facing direction to camera:
            Plane palmFacingPlane = new Plane(camToWrist, camToPalm, camToThumbMcp);

            if (_managedHand.Hand.Type == MLHandTracking.HandType.Left)
            {
                palmFacingPlane.Flip();
            }
            float palmForwardFacing = Mathf.Sign(Vector3.Dot(palmFacingPlane.normal, _mainCamera.transform.forward));

            //use thumb/palm/wrist alignment to determine amount of roll in the hand:
            Vector3 toThumbMcp     = Vector3.Normalize(_thumbMCP.positionFiltered - center);
            Vector3 toPalm         = Vector3.Normalize(center - WristCenter.positionFiltered);
            float   handRollAmount = (1 - Vector3.Dot(toThumbMcp, toPalm)) * palmForwardFacing;

            //where between the wrist and thumbMcp should we slide inwards to get the palm in the center:
            Vector3 toPalmOrigin = Vector3.Lerp(WristCenter.positionFiltered, _thumbMCP.positionFiltered, .35f);

            //get a direction from the camera to toPalmOrigin as psuedo up for use in quaternion construction:
            Vector3 toCam = Vector3.Normalize(_mainCamera.transform.position - toPalmOrigin);

            //construct a quaternion that helps get angles needed between the wrist and thumbMCP to point towards the palm center:
            Vector3    wristToThumbMcp       = Vector3.Normalize(_thumbMCP.positionFiltered - WristCenter.positionFiltered);
            Quaternion towardsCamUpReference = Quaternion.identity;

            if (wristToThumbMcp != Vector3.zero && toCam != Vector3.zero)
            {
                towardsCamUpReference = Quaternion.LookRotation(wristToThumbMcp, toCam);
            }

            //rotate the inwards vector depending on hand roll to know where to push the palm back:
            float inwardsVectorRotation = 90;

            if (_managedHand.Hand.Type == MLHandTracking.HandType.Left)
            {
                inwardsVectorRotation = -90;
            }
            towardsCamUpReference = Quaternion.AngleAxis(handRollAmount * inwardsVectorRotation, towardsCamUpReference * Vector3.forward) * towardsCamUpReference;
            Vector3 inwardsVector = towardsCamUpReference * Vector3.up;

            //slide palm location along inwards vector to get it into proper physical location in the center of the hand:
            center = toPalmOrigin - inwardsVector * thumbMcpToWristDistance;
            Vector3 deadCenter = center;

            //as the hand flattens back out balance corrected location with originally provided location for better forward origin:
            center = Vector3.Lerp(center, HandCenter.positionFiltered, Mathf.Abs(handRollAmount));

            //get a forward using the corrected palm location:
            Vector3 forward = Vector3.Normalize(center - WristCenter.positionFiltered);

            //switch back to physical center of hand - this reduces surface-to-surface movement of the center between back and palm:
            center = deadCenter;

            //get an initial hand up:
            Plane handPlane = new Plane(WristCenter.positionFiltered, _thumbMCP.positionFiltered, center);

            if (_managedHand.Hand.Type == MLHandTracking.HandType.Left)
            {
                handPlane.Flip();
            }
            Vector3 up = handPlane.normal;

            //find out how much the back of the hand is facing the camera so we have a safe set of features for a stronger forward:
            Vector3 centerToCam = Vector3.Normalize(_mainCamera.transform.position - WristCenter.positionFiltered);
            float   facingDot   = Vector3.Dot(centerToCam, up);

            if (facingDot > .5f)
            {
                float handBackFacingCamAmount = Percentage(facingDot, .5f, 1);

                //steer forward for more accuracy based on the visibility of the back of the hand:
                if (_middleMCP.Visible)
                {
                    Vector3 toMiddleMcp = Vector3.Normalize(_middleMCP.positionFiltered - center);
                    forward = Vector3.Lerp(forward, toMiddleMcp, handBackFacingCamAmount);
                }
                else if (_indexMCP.Visible)
                {
                    Vector3 inIndexMcp = Vector3.Normalize(_indexMCP.positionFiltered - center);
                    forward = Vector3.Lerp(forward, inIndexMcp, handBackFacingCamAmount);
                }
            }

            //make sure palm distance from wrist is consistant while also leveraging steered forward:
            center = WristCenter.positionFiltered + (forward * thumbMcpToWristDistance);

            //an initial rotation of the hand:
            Quaternion orientation = Quaternion.identity;

            if (forward != Vector3.zero && up != Vector3.zero)
            {
                orientation = Quaternion.LookRotation(forward, up);
            }

            //as the hand rolls counter-clockwise the thumbMcp loses accuracy so we need to interpolate to the back of the hand's features:
            if (_indexMCP.Visible && _middleMCP.Visible)
            {
                Vector3 knucklesVector = Vector3.Normalize(_middleMCP.positionFiltered - _indexMCP.positionFiltered);
                float   knucklesDot    = Vector3.Dot(knucklesVector, Vector3.up);
                if (knucklesDot > .5f)
                {
                    float counterClockwiseRoll = Percentage(Vector3.Dot(knucklesVector, Vector3.up), .35f, .7f);
                    center  = Vector3.Lerp(center, HandCenter.positionFiltered, counterClockwiseRoll);
                    forward = Vector3.Lerp(forward, Vector3.Normalize(_middleMCP.positionFiltered - HandCenter.positionFiltered), counterClockwiseRoll);
                    Plane backHandPlane = new Plane(HandCenter.positionFiltered, _indexMCP.positionFiltered, _middleMCP.positionFiltered);
                    if (_managedHand.Hand.Type == MLHandTracking.HandType.Left)
                    {
                        backHandPlane.Flip();
                    }
                    up          = Vector3.Lerp(up, backHandPlane.normal, counterClockwiseRoll);
                    orientation = Quaternion.LookRotation(forward, up);
                }
            }

            //as the wrist tilts away from the camera (with the thumb down) at extreme angles the hand center will move toward the thumb:
            float   handTiltAwayAmount          = 1 - Percentage(Vector3.Distance(HandCenter.positionFiltered, WristCenter.positionFiltered), .025f, .04f);
            Vector3 handTiltAwayCorrectionPoint = WristCenter.positionFiltered + camToWristDirection * thumbMcpToWristDistance;

            center  = Vector3.Lerp(center, handTiltAwayCorrectionPoint, handTiltAwayAmount);
            forward = Vector3.Lerp(forward, Vector3.Normalize(handTiltAwayCorrectionPoint - WristCenter.positionFiltered), handTiltAwayAmount);
            Plane wristPlane = new Plane(WristCenter.positionFiltered, _thumbMCP.positionFiltered, center);

            if (_managedHand.Hand.Type == MLHandTracking.HandType.Left)
            {
                wristPlane.Flip();
            }
            up = Vector3.Lerp(up, wristPlane.normal, handTiltAwayAmount);
            if (forward != Vector3.zero && up != Vector3.zero)
            {
                orientation = Quaternion.LookRotation(forward, up);
            }

            //steering for if thumb/index are not available from self-occlusion to help rotate the hand better outwards better:
            float forwardUpAmount = Vector3.Dot(forward, Vector3.up);

            if (forwardUpAmount > .7f && _indexMCP.Visible && _ringMCP.Visible)
            {
                float angle = 0;
                if (_managedHand.Hand.Type == MLHandTracking.HandType.Right)
                {
                    Vector3 knucklesVector = Vector3.Normalize(_ringMCP.positionFiltered - _indexMCP.positionFiltered);
                    angle  = Vector3.Angle(knucklesVector, orientation * Vector3.right);
                    angle *= -1;
                }
                else
                {
                    Vector3 knucklesVector = Vector3.Normalize(_indexMCP.positionFiltered - _ringMCP.positionFiltered);
                    angle = Vector3.Angle(knucklesVector, orientation * Vector3.right);
                }
                Quaternion selfOcclusionSteering = Quaternion.AngleAxis(angle, forward);
                orientation = selfOcclusionSteering * orientation;
            }
            else
            {
                //when palm is facing down we need to rotate some to compensate for an offset:
                float rollCorrection       = Mathf.Clamp01(Vector3.Dot(orientation * Vector3.up, Vector3.up));
                float rollCorrectionAmount = -30;
                if (_managedHand.Hand.Type == MLHandTracking.HandType.Left)
                {
                    rollCorrectionAmount = 30;
                }
                orientation = Quaternion.AngleAxis(rollCorrectionAmount * rollCorrection, forward) * orientation;
            }

            //inside the camera plane:
            InsideClipPlane = TransformUtilities.InsideClipPlane(center);

            //set pose:
            Position = center;
            Rotation = orientation;

            UpdateKeypointRotations();
        }
Exemple #43
0
    // Update is called once per frame
    void FixedUpdate()
    {
        if (!win)
        {
            ground     = null;
            isGrounded = false;
            Collider2D tempGround;
            for (int i = 0; i < feetPos.Length; i++)
            {
                tempGround = Physics2D.OverlapCircle(feetPos[i].position, checkRadius, whatIsGround);
                isGrounded = isGrounded || tempGround;
                if (tempGround)
                {
                    ground = tempGround;
                }
            }
            isGrounded = ground;

            if (isGrounded)
            {
                animator.SetBool("IsJumping", false);
                ring = ground.gameObject.GetComponent <Ring>();
                if (ring == null)
                {
                    ring = ground.gameObject.GetComponent <FreezeBlocks>().parentTransform.gameObject.GetComponent <Ring>();
                    if (ring == null)
                    {
                        Debug.LogError("Error with rings!");
                    }
                }
            }

            float move = Input.GetAxis("Horizontal");

            angle  = Mathf.Atan2(transform.position.y, transform.position.x);
            radius = Mathf.Sqrt(transform.position.x * transform.position.x + transform.position.y * transform.position.y);

            acceleration = gravity;

            if (Input.GetKey(KeyCode.Space) && isGrounded)
            {
                animator.SetBool("IsJumping", true);
                acceleration -= jump;
            }

            velocity += acceleration * Time.deltaTime;

            if (move != 0.0f)
            {
                GetComponent <SpriteRenderer>().flipX = (move < 0.0f);
            }

            if (onPlatform && !Input.GetKey(KeyCode.Space))
            {
                acceleration = 0.0f;
                velocity     = 0.0f;
            }

            if (Mathf.Abs(velocity) > maxSpeed)
            {
                velocity = Mathf.Sign(velocity) * maxSpeed;
            }

            angleVelocity = move * (moveSpeed / currentLevel.GetComponent <Ring>().radius) * Time.deltaTime;

            if (onPlatform && angleVelocity == 0.0f)
            {
                if (ring)
                {
                    if (!platform.GetComponent <FreezeBlocks>())
                    {
                        angleVelocity = (ring.rotation / ring.radius) * Mathf.Deg2Rad + Mathf.Sign(ring.rotation) * offset;
                    }
                    else if (platform.GetComponent <FreezeBlocks>() && !platform.GetComponent <FreezeBlocks>().GetIsFrozen())
                    {
                        angleVelocity = (ring.rotation / ring.radius) * Mathf.Deg2Rad + Mathf.Sign(ring.rotation) * offset;
                    }
                }
            }

            animator.SetFloat("Speed", Mathf.Abs(move));

            radius += velocity * Time.deltaTime;
            angle  += angleVelocity * Time.deltaTime;

            rotation = angle * Mathf.Rad2Deg + 90.0f;


            rb.MovePosition(new Vector2(radius * Mathf.Cos(angle), radius * Mathf.Sin(angle)));
            //rb.MoveRotation(rotation);
            transform.rotation = Quaternion.Euler(0.0f, 0.0f, rotation);
        }
        else
        {
            if (freezeTimer < 3.0f)
            {
                rb.MovePosition(new Vector2(0.0f, 0.0f));

                angleVelocity      = 50 * moveSpeed * Time.deltaTime;
                angle             += angleVelocity * Time.deltaTime;
                rotation           = angle * Mathf.Rad2Deg + 90.0f;
                transform.rotation = Quaternion.Euler(0.0f, 0.0f, rotation);
                freezeTimer       += Time.deltaTime;
            }
            else
            {
                GetComponent <SpriteRenderer>().enabled = false;
            }


            winText.GetComponent <Text>().enabled = true;
        }
    }
Exemple #44
0
        private void DrawChart(IDisplay disp, IPoint point, double[] values, double valSum, double valMin, double valMax)
        {
            if (!(disp is Display) || disp.LabelEngine.LabelGraphicsContext == null)
            {
                return;
            }

            System.Drawing.Graphics original = disp.GraphicsContext;
            try
            {
                ((Display)disp).GraphicsContext = disp.LabelEngine.LabelGraphicsContext;

                if (_symbolTable.Keys.Count == 0)
                {
                    return;
                }

                int i = 0;
                if (_type == chartType.Pie)
                {
                    #region Draw Pie

                    if (valSum == 0.0)
                    {
                        return;
                    }

                    double r = disp.mapScale / disp.dpm * _size / 2D;
                    switch (_sizeType)
                    {
                    case sizeType.ValueOfEquatesToSize:
                        double a = r * r * Math.PI * valSum / _valueEquatesToSize;
                        r = Math.Sqrt(a / Math.PI);
                        break;
                    }

                    i = 0;
                    double startAngle = 0.0;

                    Path outerPath = new Path();
                    foreach (string fieldname in _symbolTable.Keys)
                    {
                        ISymbol symbol = _symbolTable[fieldname];

                        double angle = (Math.PI * 2.0) * Math.Abs(values[i++]) / valSum;

                        Polygon poly = new Polygon();
                        Ring    ring = new Ring();
                        poly.AddRing(ring);
                        ring.AddPoint(point);

                        for (double a = startAngle, to = startAngle + angle; a < to; a += 0.01745)
                        {
                            IPoint piePoint = new Point(point.X + r * Math.Cos(a), point.Y + r * Math.Sin(a));
                            ring.AddPoint(piePoint);
                            outerPath.AddPoint(piePoint);
                        }
                        ring.AddPoint(new Point(point.X + r * Math.Cos(startAngle + angle), point.Y + r * Math.Sin(startAngle + angle)));

                        symbol.Draw(disp, poly);

                        //if (_outlineSymbol != null && ring.PointCount > 0)
                        //    outerPath.AddPoints(ring);

                        startAngle += angle;
                    }
                    if (outerPath.PointCount > 0 && _outlineSymbol != null)
                    {
                        outerPath.AddPoint(outerPath[0]);
                        _outlineSymbol.Draw(disp, new Polyline(outerPath));
                    }

                    #endregion
                }
                else if (_type == chartType.Bars)
                {
                    #region Draw Bars

                    double height    = disp.mapScale / disp.dpm * _size;
                    double width     = disp.mapScale / disp.dpm * _size / 4D;
                    double heightVal = _valueEquatesToSize;

                    switch (_sizeType)
                    {
                    case sizeType.ConstantSize:
                        if (valSum == 0.0)
                        {
                            return;
                        }
                        height *= _valueEquatesToSize / valSum;
                        break;
                    }

                    i = 0;
                    double left = -(_symbolTable.Keys.Count * width / 2.0) - (_symbolTable.Keys.Count - 1) * (disp.mapScale / disp.dpm) / 2.0;
                    foreach (string fieldname in _symbolTable.Keys)
                    {
                        ISymbol symbol = _symbolTable[fieldname];

                        double h = height * (values[i++] / heightVal);
                        if (Math.Abs(h) < disp.mapScale / disp.dpm)
                        {
                            h = disp.mapScale / disp.dpm;
                        }

                        Polygon poly = new Polygon();
                        Ring    ring = new Ring();
                        poly.AddRing(ring);
                        ring.AddPoint(new Point(point.X + left, point.Y));
                        ring.AddPoint(new Point(point.X + left, point.Y + h));
                        ring.AddPoint(new Point(point.X + left + width, point.Y + h));
                        ring.AddPoint(new Point(point.X + left + width, point.Y));

                        symbol.Draw(disp, poly);

                        if (_outlineSymbol != null && ring.PointCount > 0)
                        {
                            ring.AddPoint(new Point(point.X + left, point.Y));
                            _outlineSymbol.Draw(disp, new Polyline(ring));
                        }
                        left += width + (disp.mapScale / disp.dpm);
                    }

                    #endregion
                }
                else if (_type == chartType.Stack)
                {
                    #region Draw Stack
                    double height    = disp.mapScale / disp.dpm * _size;
                    double width     = disp.mapScale / disp.dpm * _size / 4D;
                    double heightVal = _valueEquatesToSize;

                    Path outerPath = new Path();

                    switch (_sizeType)
                    {
                    case sizeType.ConstantSize:
                        if (valSum == 0.0)
                        {
                            return;
                        }
                        height *= _valueEquatesToSize / valSum;
                        break;
                    }

                    i = 0;
                    double left = -width / 2.0, bottom = 0D;
                    foreach (string fieldname in _symbolTable.Keys)
                    {
                        ISymbol symbol = _symbolTable[fieldname];

                        double h = height * (values[i++] / heightVal);
                        if (Math.Abs(h) < disp.mapScale / disp.dpm)
                        {
                            h = disp.mapScale / disp.dpm;
                        }

                        Polygon poly = new Polygon();
                        Ring    ring = new Ring();
                        poly.AddRing(ring);
                        ring.AddPoint(new Point(point.X + left, point.Y + bottom));
                        ring.AddPoint(new Point(point.X + left, point.Y + bottom + h));
                        ring.AddPoint(new Point(point.X + left + width, point.Y + bottom + h));
                        ring.AddPoint(new Point(point.X + left + width, point.Y + bottom));

                        if (_outlineSymbol != null)
                        {
                            if (i == 1)
                            {
                                outerPath.AddPoint(new Point(point.X + left, point.Y + bottom));
                            }
                            if (i == _symbolTable.Keys.Count)
                            {
                                outerPath.AddPoint(new Point(point.X + left, point.Y + bottom + h));
                                outerPath.AddPoint(new Point(point.X + left + width, point.Y + bottom + h));
                                outerPath.AddPoint(new Point(point.X + left + width, point.Y));
                                outerPath.AddPoint(outerPath[0]);
                            }
                        }

                        symbol.Draw(disp, poly);
                        bottom += h;
                    }
                    if (_outlineSymbol != null && outerPath.PointCount > 0)
                    {
                        _outlineSymbol.Draw(disp, new Polyline(outerPath));
                    }
                    #endregion
                }
            }
            finally
            {
                ((Display)disp).GraphicsContext = original;
            }
        }
	public void recreateFighterItem(int x, int y, int i){
		Item item;
		if(PlayerPrefs.GetString("Fighter Item type" + i) == "ManaPotion"){
			item = new ManaPotion();
			inventory.addItem(x,y,item, inventorySlots, inventoryItems);
		}
		else if(PlayerPrefs.GetString("Fighter Item type"  + i) == "HealthPotion"){
			item = new HealthPotion();
			inventory.addItem(x,y,item, inventorySlots, inventoryItems);
		}
		else if(PlayerPrefs.GetString("Fighter Item type"  + i) == "Axe"){
			item = new Axe();
			inventory.addItem(x,y,item, inventorySlots, inventoryItems);
		}
		else if(PlayerPrefs.GetString( "Fighter Item type" + i) == "Ring"){
			item = new Ring();
			inventory.addItem(x,y,item, inventorySlots, inventoryItems);
		}
		else if(PlayerPrefs.GetString("Fighter Item type" + i) == "Chest"){
			item = new Chest();
			inventory.addItem(x,y,item, inventorySlots, inventoryItems);
		}
		else if(PlayerPrefs.GetString("Fighter Item type" + i) == "Boots"){
			item = new Boots();
			inventory.addItem(x,y,item, inventorySlots, inventoryItems);
		}
		else if(PlayerPrefs.GetString("Fighter Item type"  + i) == "Amulet"){
			item = new Amulet();
			inventory.addItem(x,y,item, inventorySlots, inventoryItems);
		}
		else if(PlayerPrefs.GetString( "Fighter Item type" + i) == "Sword"){
			item = new Sword();
			inventory.addItem(x,y,item, inventorySlots, inventoryItems);
		}
	}
 /// <summary>
 ///   Initializes the strategies with the specified nodes and cluster configuration
 /// </summary>
 /// <param name="nodes"> The nodes. </param>
 /// <param name="config"> The config. </param>
 public RandomConnectionStrategy(Ring nodes, ClusterConfig config)
 {
     _nodes  = nodes;
     _config = config;
     _rnd    = new Random((int)DateTime.Now.Ticks);
 }
Exemple #47
0
 private static void player_addRing(object sender, EventArgsCommand e)
 {
     if (e.Command.CalledArgs.Length > 0)
     {
         if (e.Command.CalledArgs[0].IsInt32())
         {
             var toAdd = new Ring(e.Command.CalledArgs[0].AsInt32());
             Game1.player.addItemByMenuIfNecessary(toAdd);
             Log.Async($"Given {toAdd.Name} to {Game1.player.Name}");
         }
         else
         {
             Log.AsyncR("<item> is invalid");
         }
     }
     else
     {
         Log.LogObjectValueNotSpecified();
     }
 }
Exemple #48
0
        /// <summary>This static method allows you to fix the seams of the source mesh at runtime.</summary>
        public static void Generate(Mesh source, Mesh output, P3dCoord coord, float threshold, float border)
        {
            if (source != null && output != null && border != 0.0f)
            {
                output.Clear(false);

                var points     = new Dictionary <Vector2, Point>();
                var insertions = new List <Insertion>();
                var submeshes  = new List <List <int> >();
                var coords     = default(Vector2[]);

                switch (coord)
                {
                case P3dCoord.First: coords = source.uv; break;

                case P3dCoord.Second: coords = source.uv2; break;

                case P3dCoord.Third: coords = source.uv3; break;

                case P3dCoord.Fourth: coords = source.uv4; break;
                }

                for (var i = 0; i < coords.Length; i++)
                {
                    var uv = coords[i];

                    uv  *= 16384.0f;
                    uv.x = Mathf.Floor(uv.x);
                    uv.y = Mathf.Floor(uv.y);
                    uv  /= 16384.0f;

                    coords[i] = uv;

                    AddPoint(points, uv, i);
                }

                var rings       = new List <Ring>();
                var vertexIndex = source.vertexCount;

                for (var i = 0; i < source.subMeshCount; i++)
                {
                    var edges   = new List <Edge>();
                    var indices = new List <int>(); source.GetTriangles(indices, i);

                    submeshes.Add(indices);

                    if (coords.Length > 0)
                    {
                        for (var j = 0; j < indices.Count; j += 3)
                        {
                            var pointA = points[coords[indices[j + 0]]];
                            var pointB = points[coords[indices[j + 1]]];
                            var pointC = points[coords[indices[j + 2]]];

                            AddTriangle(edges, pointA, pointB, pointC);
                        }
                    }
#if UNITY_EDITOR
                    if (P3dSeamFixer_Editor.DebugScale > 0.0f)
                    {
                        for (var j = edges.Count - 1; j >= 0; j--)
                        {
                            var edge = edges[j];

                            if (edge.Used == true)
                            {
                                Debug.DrawLine(edge.PointA.Coord * P3dSeamFixer_Editor.DebugScale, edge.PointB.Coord * P3dSeamFixer_Editor.DebugScale, new Color(1.0f, 0.0f, 0.0f, 0.5f), 1.0f);
                            }
                            else
                            {
                                Debug.DrawLine(edge.PointA.Coord * P3dSeamFixer_Editor.DebugScale, edge.PointB.Coord * P3dSeamFixer_Editor.DebugScale, new Color(1.0f, 1.0f, 1.0f, 0.5f), 1.0f);
                            }
                        }
                    }
#endif
                    for (var j = edges.Count - 1; j >= 0; j--)
                    {
                        var edge = edges[j];

                        if (edge.Used == false)
                        {
                            edge.Used = true;

                            var ring = new Ring();

                            ring.Points.Add(edge.PointA);
                            ring.Points.Add(edge.PointB);

                            TraceEdges(ring, edge.PointB);

                            if (ring.Points.Count > 2)
                            {
                                rings.Add(ring);

                                for (var k = 0; k < ring.Points.Count; k++)
                                {
                                    var pointA = ring.GetPoint(k - 1);
                                    var pointB = ring.GetPoint(k);
                                    var pointC = ring.GetPoint(k + 1);

                                    var normalA   = (pointA.Coord - pointB.Coord).normalized; normalA = new Vector2(-normalA.y, normalA.x);
                                    var normalB   = (pointB.Coord - pointC.Coord).normalized; normalB = new Vector2(-normalB.y, normalB.x);
                                    var average   = normalA + normalB;
                                    var magnitude = average.sqrMagnitude;
                                    var insertion = new Insertion();

                                    insertion.Index    = pointB.Index;
                                    insertion.NewCoord = pointB.Coord;
                                    insertion.NewIndex = vertexIndex++;

                                    pointB.Outer = insertion;

                                    if (magnitude > 0.0f)
                                    {
                                        magnitude = Mathf.Sqrt(magnitude);

                                        insertion.NewCoord += (average / magnitude) * border;
                                    }

                                    insertions.Add(insertion);
                                }

                                for (var k = 0; k < ring.Points.Count; k++)
                                {
                                    var pointA = ring.GetPoint(k);
                                    var pointB = ring.GetPoint(k + 1);
                                    var indexA = pointA.Index;
                                    var indexB = pointB.Index;
                                    var indexC = pointA.Outer.NewIndex;
                                    var indexD = pointB.Outer.NewIndex;
                                    var coordA = pointA.Coord;
                                    var coordB = pointB.Coord;
                                    var coordC = pointA.Outer.NewCoord;
                                    var coordD = pointB.Outer.NewCoord;

                                    indices.Add(indexA);
                                    indices.Add(indexB);
                                    indices.Add(indexC);

                                    indices.Add(indexD);
                                    indices.Add(indexC);
                                    indices.Add(indexB);
#if UNITY_EDITOR
                                    if (P3dSeamFixer_Editor.DebugScale > 0.0f)
                                    {
                                        Debug.DrawLine(coordA * P3dSeamFixer_Editor.DebugScale, coordB * P3dSeamFixer_Editor.DebugScale, new Color(0.0f, 1.0f, 0.0f, 0.5f), 1.0f);
                                        Debug.DrawLine(coordB * P3dSeamFixer_Editor.DebugScale, coordC * P3dSeamFixer_Editor.DebugScale, new Color(0.0f, 1.0f, 0.0f, 0.5f), 1.0f);
                                        Debug.DrawLine(coordC * P3dSeamFixer_Editor.DebugScale, coordA * P3dSeamFixer_Editor.DebugScale, new Color(0.0f, 1.0f, 0.0f, 0.5f), 1.0f);

                                        Debug.DrawLine(coordD * P3dSeamFixer_Editor.DebugScale, coordC * P3dSeamFixer_Editor.DebugScale, new Color(0.0f, 1.0f, 0.0f, 0.5f), 1.0f);
                                        Debug.DrawLine(coordC * P3dSeamFixer_Editor.DebugScale, coordB * P3dSeamFixer_Editor.DebugScale, new Color(0.0f, 1.0f, 0.0f, 0.5f), 1.0f);
                                        Debug.DrawLine(coordB * P3dSeamFixer_Editor.DebugScale, coordD * P3dSeamFixer_Editor.DebugScale, new Color(0.0f, 1.0f, 0.0f, 0.5f), 1.0f);
                                    }
#endif
                                }
                            }
                        }
                    }
                }

                FixSeams(source, output, submeshes, rings, insertions, coord);
            }
        }
Exemple #49
0
        //Graph with 4 nodes and not 3-colorable
        static void Test8()
        {
            Ring r = new Ring(Field.Real, new string[] { "x", "y", "z", "t" });

            r.FixOrder(new string[] { "x", "y", "z", "t" });


            Polynomial f1 = new Polynomial(r);

            f1.AddTerm(1, new int[] { 3, 0, 0, 0 });
            f1.AddTerm(-1, new int[] { 0, 0, 0, 0 });


            Polynomial f2 = new Polynomial(r);

            f2.AddTerm(1, new int[] { 0, 3, 0, 0 });
            f2.AddTerm(-1, new int[] { 0, 0, 0, 0 });

            Polynomial f3 = new Polynomial(r);

            f3.AddTerm(1, new int[] { 0, 0, 3, 0 });
            f3.AddTerm(-1, new int[] { 0, 0, 0, 0 });

            Polynomial f4 = new Polynomial(r);

            f4.AddTerm(1, new int[] { 0, 2, 0, 0 });
            f4.AddTerm(1, new int[] { 0, 1, 1, 0 });
            f4.AddTerm(1, new int[] { 0, 0, 2, 0 });

            Polynomial f5 = new Polynomial(r);

            f5.AddTerm(1, new int[] { 2, 0, 0, 0 });
            f5.AddTerm(1, new int[] { 1, 0, 1, 0 });
            f5.AddTerm(1, new int[] { 0, 0, 2, 0 });

            Polynomial f6 = new Polynomial(r);

            f6.AddTerm(1, new int[] { 2, 0, 0, 0 });
            f6.AddTerm(1, new int[] { 1, 1, 0, 0 });
            f6.AddTerm(1, new int[] { 0, 2, 0, 0 });



            Polynomial f7 = new Polynomial(r);

            f7.AddTerm(1, new int[] { 0, 0, 0, 3 });
            f7.AddTerm(-1, new int[] { 0, 0, 0, 0 });

            Polynomial f8 = new Polynomial(r);

            f8.AddTerm(1, new int[] { 2, 0, 0, 0 });
            f8.AddTerm(1, new int[] { 1, 0, 0, 1 });
            f8.AddTerm(1, new int[] { 0, 0, 0, 2 });

            Polynomial f9 = new Polynomial(r);

            f9.AddTerm(1, new int[] { 0, 0, 2, 0 });
            f9.AddTerm(1, new int[] { 0, 0, 1, 1 });
            f9.AddTerm(1, new int[] { 0, 0, 0, 2 });


            Polynomial f10 = new Polynomial(r);

            f10.AddTerm(1, new int[] { 0, 2, 0, 0 });
            f10.AddTerm(1, new int[] { 0, 1, 0, 1 });
            f10.AddTerm(1, new int[] { 0, 0, 0, 2 });


            Ideal I = new Ideal(new Polynomial[] { f1, f2, f6, f3, f9, f4, f5, f7, f10, f8 }, r);

            Console.WriteLine("__________Generator_________________");
            var sys = I.GeneratorSet;

            foreach (var p in sys)
            {
                Console.WriteLine(p);
            }


            Console.WriteLine("__________Gröbner Basis__________________");
            var gb = I.GröbnerBasis();

            foreach (var p in gb)
            {
                Console.WriteLine(p);
            }

            Console.WriteLine("_________Minimal Gröbner Basis___________________");

            var minimal = I.MinimalGröbnerBasis();

            foreach (var p in minimal)
            {
                Console.WriteLine(p);
            }

            Console.WriteLine("______________Reduced Gröbner Basis______________");


            var reduced = I.ReducedGrobnerBasis();

            foreach (var p in reduced)
            {
                Console.WriteLine(p);
            }

            Console.WriteLine("__________Membership__________________");
            Console.WriteLine(I.Member(f1));
        }
Exemple #50
0
    void Update()
    {
        //set distance
        distRing = Vector2.Distance(transform.position, RingTrns.position);
        distStop = Vector2.Distance(transform.position, mainSPWN.stops[getOff].stdSpawner.transform.position);

        // Get Off
        if (getOff == Ring.detectZone() && distStop < 6 || gettingOff)
        {
            gettingOff = true;
            //set student rotation to stop
            if (Ring.detectZone() != 99)
            {
                float AngleRad2 = Mathf.Atan2(mainSPWN.stops[Ring.detectZone()].stdSpawner.transform.position.y - gameObject.transform.position.y, mainSPWN.stops[Ring.detectZone()].stdSpawner.transform.position.x - gameObject.transform.position.x);
                float AngleDeg2 = (180 / Mathf.PI) * AngleRad2;
                stopRot = Quaternion.Euler(0, 0, AngleDeg2 - 90);
            }
            gameObject.transform.rotation = stopRot;
            //student walk to stop
            anim.SetBool("isWalking", true);
            if (Ring.detectZone() != 99)
            {
                stopPos = mainSPWN.stops[Ring.detectZone()].stdSpawner.transform.position;
            }

            transform.position = Vector3.MoveTowards(transform.position, stopPos, speed * Time.deltaTime);
            if (gameObject.transform.position == stopPos)
            {
                Destroy(gameObject); //walk to building
                Score.score++;       //add score at drop off
            }
        }
        //Get On
        else if (Ring.detectZone() != 99 && Ring.doors && distRing < 7 && RingTrns.transform.childCount - 1 < 50)
        {
            //set student rotation to ring
            float AngleRad = Mathf.Atan2(RingTrns.position.y - gameObject.transform.position.y, RingTrns.position.x - gameObject.transform.position.x);
            float AngleDeg = (180 / Mathf.PI) * AngleRad;
            gameObject.transform.rotation = Quaternion.Euler(0, 0, AngleDeg - 90);
            //student walk to ring
            anim.SetBool("isWalking", true);
            transform.position = Vector3.MoveTowards(transform.position, RingTrns.position, speed * Time.deltaTime);
            if (transform.position == RingTrns.transform.position)
            {
                gameObject.transform.parent = RingTrns;
                gameObject.SetActive(false);
                Score.score++; //add score at pickup
            }
        }
        //Student didn't picked up
        else if (gameObject.transform.position != initPos && Ring.detectZone() == 99 && !gettingOff)
        {
            anim.SetBool("isWalking", true);
            transform.position = Vector3.MoveTowards(transform.position, initPos, speed * Time.deltaTime);
        }
        //Idle at Stop
        else
        {
            anim.SetBool("isWalking", false);
            //set student rotation to ring
            float AngleRad = Mathf.Atan2(RingTrns.position.y - gameObject.transform.position.y, RingTrns.position.x - gameObject.transform.position.x);
            float AngleDeg = (180 / Mathf.PI) * AngleRad;
            gameObject.transform.rotation = Quaternion.Euler(0, 0, AngleDeg - 90);
        }
    }
 // Initialize the RingLoader
 public RingLoader(Ring ring)
 {
     this.ring = ring;
 }
Exemple #52
0
 public Accuracy(Ring ring) : base(ring)
 {
 }
Exemple #53
0
        public void Decode(ClientConnection pConnection, MaplePacket pPacket)
        {
            pPacket.Skip(8); // Flag

#if LOCALE_GMS
            pPacket.Skip(1);
#endif

            {
                // Added GMS V.132 
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
            }

#if LOCALE_EMS
            pPacket.Skip(1);
#endif

            int tmp = pPacket.ReadByte();
            pPacket.Skip(tmp * 4);

            tmp = pPacket.ReadInt();
            pPacket.Skip(tmp * (4 + 8));


#if LOCALE_GMS
            pPacket.Skip(1);
#endif

            if (pPacket.ReadBool())
            {
                tmp = pPacket.ReadInt();
                pPacket.Skip(tmp * 8);
                tmp = pPacket.ReadInt();
                pPacket.Skip(tmp * 8);
            }

            Stats = new GW_CharacterStat();
            Stats.Decode(pPacket);

            this.BuddylistSize = pPacket.ReadByte();
#if LOCALE_EMS
            pPacket.ReadByte();
#endif

            if (pPacket.ReadBool()) BlessingOfTheFairy = pPacket.ReadString();
            else BlessingOfTheFairy = null;
            if (pPacket.ReadBool()) BlessingOfEmpress = pPacket.ReadString();
            else BlessingOfEmpress = null;
            if (pPacket.ReadBool()) UltimateExplorer = pPacket.ReadString();
            else UltimateExplorer = null;

            Stats.DecodeMesos(pPacket); // .-.

#if LOCALE_EMS
            pPacket.ReadByte(); // Bool check
            pPacket.ReadInt();
#endif


            // Unknown stuff here

            for (int i = pPacket.ReadInt(); i > 0; i--)
            {
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadLong();
            }

#if LOCALE_GMS
            // Magical potion pots!!!
            for (int i = pPacket.ReadInt(); i > 0; i--) // V.126
            {
                pPacket.ReadInt(); // Potion pot ID
                pPacket.ReadInt(); // Max value
                pPacket.ReadInt(); // HP
                pPacket.ReadInt(); // ??? (Not max value of MP)
                pPacket.ReadInt(); // MP

                pPacket.ReadLong(); // Start date O.o?
                pPacket.ReadLong(); // End date O.o?
            }
#endif


#if LOCALE_GMS
            // V.142 - RED stuff?

            for (int i = pPacket.ReadInt(); i > 0; i--)
            {
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadByte();
                pPacket.ReadInt();
                pPacket.ReadInt();
            }

            {
                pPacket.ReadInt();
                for (int i = 3; i > 0; i--)
                {
                    pPacket.ReadInt();
                    pPacket.ReadInt();
                }
            }


            for (int i = pPacket.ReadInt(); i > 0; i--)
                pPacket.ReadInt();

            if (pPacket.ReadBool())
            {
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadLong();
                pPacket.ReadLong();
                pPacket.ReadLong();
            }

            for (int j = 0; j < 2; j++) // called 2 times under each other!
            {
                for (int i = pPacket.ReadByte(); i > 0; i--)
                {
                    pPacket.ReadByte();
                    pPacket.ReadInt();
                    pPacket.ReadByte();
                    pPacket.ReadInt();
                    pPacket.ReadInt();
                    pPacket.ReadInt();
                    pPacket.ReadInt();
                    pPacket.ReadInt();
                    pPacket.ReadInt();
                    pPacket.ReadString();
                }
            }
#endif

#if LOCALE_EMS
            // REMOVED GMS V.141?!
            for (int i = pPacket.ReadInt(); i > 0; i--) // V.137
            {
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt(); 
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
            }

            pPacket.ReadInt();
            for (int i = 6; i > 0; i--)
            {
                pPacket.ReadInt();
            }


            for (int i = pPacket.ReadInt(); i > 0; i--)
            {
                pPacket.ReadInt();
            }


            for (int i = pPacket.ReadInt(); i > 0; i--)
            {
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadString();
            }


            for (int i = pPacket.ReadInt(); i > 0; i--)
            {
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadString();
            }

#endif

            Inventory = new CharacterInventory();
            Inventory.Decode(pConnection, pPacket);

            //UnknownIntegerListNumber3 = new Dictionary<int, long>();
            for (int i = pPacket.ReadInt(); i > 0; i--)
            {
                pPacket.ReadInt();
                pPacket.ReadLong();
                //UnknownIntegerListNumber3.Add(pPacket.ReadInt(), pPacket.ReadLong());
            }

            //UnknownIntegerListNumber4 = new Dictionary<long, long>();
            for (int i = pPacket.ReadInt(); i > 0; i--)
            {
                pPacket.ReadLong();
                pPacket.ReadLong();
                //UnknownIntegerListNumber4.Add(pPacket.ReadLong(), pPacket.ReadLong());
            }


            while (true)
            {
                byte val = pPacket.ReadByte();
                if (val == 0) break;

                {
                    pPacket.ReadInt();
                    pPacket.ReadByte();
                    pPacket.ReadByte();
                    pPacket.ReadInt();
                    pPacket.ReadInt();
                    pPacket.ReadInt();
                    pPacket.ReadInt();
                    pPacket.ReadByte();
                    pPacket.ReadInt();
                    pPacket.ReadLong();
                    pPacket.ReadLong();
                    pPacket.ReadLong();
                    pPacket.ReadLong();
                }
            }


            Skills = new CharacterSkills();
            Skills.Decode(pConnection, pPacket);

            Quests = new CharacterQuests();
            Quests.Decode(pConnection, pPacket);


            // Match
            for (int i = pPacket.ReadShort(); i > 0; i--)
            {
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
            }


            {

                Rings = new List<Ring>();
                MarriedWith = null;

                // Couple
                for (int i = pPacket.ReadShort(); i > 0; i--)
                {
                    Rings.Add(new Ring(Ring.Type.Couple, pPacket));
                }

                // Friend
                for (int i = pPacket.ReadShort(); i > 0; i--)
                {
                    Rings.Add(new Ring(Ring.Type.Friend, pPacket));
                }

                // Marriage
                for (int i = pPacket.ReadShort(); i > 0; i--)
                {
                    Ring ring = new Ring(Ring.Type.Marriage, pPacket, Stats.Name);
                    Rings.Add(ring);

                    MarriedWith = ring.FriendName;
                }
            }


            Inventory.DecodeTeleportRocks(pPacket);

#if LOCALE_GMS
            Monsterbook = new CharacterMonsterBook();
            Monsterbook.Decode(pPacket);

            pPacket.ReadInt(); // -1?

            for (int i = pPacket.ReadShort(); i > 0; i--)
            {
                pPacket.ReadShort();
            }

            {
                // Newyear cards... meh
                // WHAT MEH, SOMEONE HAS THIS FFS D:!!!

                for (short i = pPacket.ReadShort(); i > 0; i--)
                {
                    pPacket.ReadInt(); // Card ID?
                    pPacket.ReadInt(); // Sender ID
                    pPacket.ReadString(); // Sender name
                    pPacket.ReadByte(); // GENDER..?
                    pPacket.ReadLong(); // Sent at?
                    pPacket.ReadInt(); // Receiver ID
                    pPacket.ReadString(); // Receiver name
                    pPacket.ReadByte();
                    pPacket.ReadByte();
                    pPacket.ReadLong(); // Receive date?
                    pPacket.ReadString(); // Message
                }
            }
#else
            for (int i = pPacket.ReadShort(); i > 0; i--)
            {
                pPacket.ReadShort();
                pPacket.ReadString();
            }
#endif

            Quests.DecodePQ(pConnection, pPacket);

            if (GameHelper.IsWildHunter(Stats.JobID))
            {
                pPacket.ReadByte(); // Level

                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt(); // Caught mob
            }

            Quests.DecodePQDone(pConnection, pPacket);

            for (int i = pPacket.ReadShort(); i > 0; i--)
            {
                short cnt = pPacket.ReadShort();
                int unk = pPacket.ReadInt(); // 9010040 | Conor (NPC)
                if (cnt > 0 && unk > 0)
                {
                    for (short j = 0; j < cnt; j++)
                    {
                        pPacket.ReadInt(); // 9010040 | Conor (NPC)
                        pPacket.ReadShort();
                        pPacket.ReadInt(); // 4330019 | Pink Coin Purse
                        pPacket.ReadShort();
                    }
                }
            }

            for (int i = 13; i > 0; i--)
            {
                pPacket.ReadInt(); // Stolen Skills
            }

            for (int i = 4; i > 0; i--)
            {
                pPacket.ReadInt(); // Chosen Skills?
            }

            // Inner Stats
            Abilities = new List<Tuple<byte, int, byte>>();
            for (int i = pPacket.ReadShort(); i > 0; i--)
            {
                byte id = pPacket.ReadByte(); // 'ID'
                int skillid = pPacket.ReadInt(); // Skill ID
                byte level = pPacket.ReadByte(); // Level
                pPacket.ReadByte(); // Rank
                Abilities.Add(new Tuple<byte, int, byte>(id, skillid, level));
            }

#if LOCALE_GMS
            {
                // V.134
                for (int i = pPacket.ReadInt(); i > 0; i--)
                {
                    pPacket.ReadString();

                    pPacket.ReadInt();
                    pPacket.ReadString();

                    for (int j = pPacket.ReadInt(); j > 0; j--)
                    {
                        pPacket.ReadByte();
                    }
                }

                pPacket.ReadByte();
            }
#endif

            Stats.HonourLevel = pPacket.ReadInt();
            Stats.HonourExp = pPacket.ReadInt();

            {
                byte unk = pPacket.ReadByte();
                if (unk == 1)
                {
                    while (true)
                    {
                        tmp = pPacket.ReadUShort();
                        if (tmp <= 0) break;

                        while (true)
                        {
                            ushort tmp2 = pPacket.ReadUShort();
                            if (tmp2 <= 0) break;

                            pPacket.ReadInt();
                            pPacket.ReadInt();
                        }
                    }
                }
                else
                {
                    while (true)
                    {
                        tmp = pPacket.ReadUShort();
                        if (tmp <= 0) break;

                        pPacket.ReadUShort();
                        pPacket.ReadInt();
                        pPacket.ReadInt();
                    }
                }
            }

            if (pPacket.ReadBool())
            {
                // Wat.
                ItemBase.DecodeItemData(pConnection, pPacket);
                pPacket.ReadInt();
            }


            {
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadByte();
            }


            {
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadLong();
            }

#if LOCALE_EMS
            pPacket.ReadBool();
            pPacket.ReadBool();
#endif
            {
                EvolutionCards = new List<EvolutionCard>();

                for (short i = pPacket.ReadShort(); i > 0; i--)
                {
                    var card = new EvolutionCard();
                    card.Decode(pConnection, pPacket);
                    card.Block = 1;
                    EvolutionCards.Add(card);
                }

                for (short i = pPacket.ReadShort(); i > 0; i--)
                {
                    var card = new EvolutionCard();
                    card.Decode(pConnection, pPacket);
                    card.Block = 2;
                    EvolutionCards.Add(card);
                }

            }

#if LOCALE_EMS
            if (pPacket.ReadBool())
            {
                // Wat.
                ItemBase.DecodeItemData(pConnection, pPacket);
                pPacket.ReadInt();
                pPacket.ReadInt();
            }
#endif

#if LOCALE_EMS
            // No farm info

            for (short i = pPacket.ReadShort(); i > 0; i--)
            {
                pPacket.Skip(20);
            }

#else
            {
                // V.134
                for (byte i = pPacket.ReadByte(); i > 0; i--)
                {
                    pPacket.ReadInt();
                    pPacket.ReadLong();
                }
            }

            {
                // V.134
                // FARM INFO. Creating... = not yet created farm. Else: farmname
                pPacket.ReadString(); // Creating...
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadByte();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();

                pPacket.ReadInt();
                pPacket.ReadInt();
            }

#if LOCALE_GMS
            if (pPacket.ReadBool())
            {
                // Wat.
                ItemBase.DecodeItemData(pConnection, pPacket);
                pPacket.ReadInt();
                pPacket.ReadInt();
            }
#endif

            {
                // V.141
                pPacket.ReadInt();
                pPacket.ReadLong(); // A bit off here, should be filetime value
                pPacket.ReadInt();
            }

            pPacket.Skip(84); // I don't even

            pPacket.ReadByte();

            {
                for (short i = pPacket.ReadShort(); i > 0; i--)
                {
                    pPacket.ReadShort();
                    pPacket.ReadShort();
                }
            }

            {
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();

                pPacket.Skip(32);
            }

            {
                if (pPacket.ReadInt() > 0)
                {
                    for (int i = 0; i < 3; i++)
                    {
                        pPacket.Skip(4 + 4 + 4);
                        pPacket.ReadString();
                        pPacket.Skip(4 * 7);
                        pPacket.Skip(8 * 4);
                        pPacket.Skip(4 * 4);
                        pPacket.Skip(1 * 5);
                        pPacket.Skip(4 * 3);
                        pPacket.ReadString();
                        pPacket.Skip(4 * 2);
                        pPacket.ReadByte();

                        byte tmptmp = pPacket.ReadByte();
                        if ((tmptmp & 0x01) != 0)
                        {
                            pPacket.ReadInt();
                            pPacket.ReadString();
                            pPacket.Skip(24);
                        }

                        for (int j = pPacket.ReadInt(); j > 0; j++)
                        {
                            pPacket.Skip(4 * 9);
                        }
                    }
                }
            }

            // Removed in V.141
            //pPacket.ReadInt(); // I DONT EVEN D:
#endif
        }
Exemple #54
0
        public List <BaseItem> GetAllItemsInNpcBag(byte bag, int npcId)
        {
            DbParameter bagIdParameter = _db.CreateParameter(DbNames.GETALLNPCITEMSBYBAGID_BAGID_PARAMETER, bag);

            bagIdParameter.DbType = DbType.Byte;

            DbParameter characterIdParameter = _db.CreateParameter(DbNames.GETALLNPCITEMSBYBAGID_NPCID_PARAMETER, npcId);

            characterIdParameter.DbType = DbType.Int32;

            List <BaseItem> items = new List <BaseItem>();

            _db.Open();

            DbDataReader reader = _db.ExcecuteReader(DbNames.GETALLNPCITEMSBYBAGID_STOREDPROC, CommandType.StoredProcedure, bagIdParameter, characterIdParameter);

            int ordinalITEM_REFERENCEID    = reader.GetOrdinal(DbNames.ITEM_REFID);
            int ordinalITEM_BTYPE          = reader.GetOrdinal(DbNames.ITEM_BTYPE);
            int ordinalITEM_BKIND          = reader.GetOrdinal(DbNames.ITEM_BKIND);
            int ordinalITEM_VISUALID       = reader.GetOrdinal(DbNames.ITEM_VISUALID);
            int ordinalITEM_CLASS          = reader.GetOrdinal(DbNames.ITEM_CLASS);
            int ordinalITEM_AMOUNT         = reader.GetOrdinal(DbNames.ITEM_AMOUNT);
            int ordinalITEM_PRICE          = reader.GetOrdinal(DbNames.ITEM_PRICE);
            int ordinalITEM_LEVEL          = reader.GetOrdinal(DbNames.ITEM_LEVEL);
            int ordinalITEM_DEX            = reader.GetOrdinal(DbNames.ITEM_DEX);
            int ordinalITEM_STR            = reader.GetOrdinal(DbNames.ITEM_STR);
            int ordinalITEM_STA            = reader.GetOrdinal(DbNames.ITEM_STA);
            int ordinalITEM_ENE            = reader.GetOrdinal(DbNames.ITEM_ENE);
            int ordinalITEM_DURABILITY     = reader.GetOrdinal(DbNames.ITEM_DURABILITY);
            int ordinalITEM_DAMAGE         = reader.GetOrdinal(DbNames.ITEM_DAMAGE);
            int ordinalITEM_DEFENCE        = reader.GetOrdinal(DbNames.ITEM_DEFENCE);
            int ordinalITEM_ATTACKRATING   = reader.GetOrdinal(DbNames.ITEM_ATTACKRATING);
            int ordinalITEM_ATTACKSPEED    = reader.GetOrdinal(DbNames.ITEM_ATTACKSPEED);
            int ordinalITEM_ATTACKRANGE    = reader.GetOrdinal(DbNames.ITEM_ATTACKRANGE);
            int ordinalITEM_INCMAXLIFE     = reader.GetOrdinal(DbNames.ITEM_INCMAXLIFE);
            int ordinalITEM_INCMAXMANA     = reader.GetOrdinal(DbNames.ITEM_INCMAXMANA);
            int ordinalITEM_LIFEREGEN      = reader.GetOrdinal(DbNames.ITEM_LIFEREGEN);
            int ordinalITEM_MANAREGEN      = reader.GetOrdinal(DbNames.ITEM_MANAREGEN);
            int ordinalITEM_CRITICAL       = reader.GetOrdinal(DbNames.ITEM_CRITICAL);
            int ordinalITEM_TOMAPID        = reader.GetOrdinal(DbNames.ITEM_TOMAPID);
            int ordinalITEM_IMBUERATE      = reader.GetOrdinal(DbNames.ITEM_IMBUERATE);
            int ordinalITEM_IMBUEINCREASE  = reader.GetOrdinal(DbNames.ITEM_IMBUEINCREASE);
            int ordinalITEM_BOOKSKILLID    = reader.GetOrdinal(DbNames.ITEM_BOOKSKILLID);
            int ordinalITEM_BOOKSKILLLEVEL = reader.GetOrdinal(DbNames.ITEM_BOOKSKILLLEVEL);
            int ordinalITEM_BOOKSKILLDATA  = reader.GetOrdinal(DbNames.ITEM_BOOKSKILLDATA);
            int ordinalITEM_MAXPOLISHTRIES = reader.GetOrdinal(DbNames.ITEM_MAXPOLISHTRIES);
            int ordinalITEM_MAXIMBUETRIES  = reader.GetOrdinal(DbNames.ITEM_MAXIMBUES);
            int ordinalITEM_BAG            = reader.GetOrdinal(DbNames.ITEM_BAG);
            int ordinalITEM_SLOT           = reader.GetOrdinal(DbNames.ITEM_SLOT);
            int ordinalITEM_SIZEX          = reader.GetOrdinal(DbNames.ITEM_SIZEX);
            int ordinalITEM_SIZEY          = reader.GetOrdinal(DbNames.ITEM_SIZEY);

            while (reader.Read())
            {
                BaseItem b = null;

                int BType = reader.GetByte(ordinalITEM_BTYPE);
                int BKind = reader.GetByte(ordinalITEM_BKIND);



                if (BType == (byte)bType.Weapon || BType == (byte)bType.Clothes || BType == (byte)bType.Hat || BType == (byte)bType.Necklace ||
                    BType == (byte)bType.Ring || BType == (byte)bType.Shoes || BType == (byte)bType.Cape)
                {
                    if (BKind == (byte)bKindWeapons.Sword && BType == (byte)bType.Weapon)
                    {
                        b = new Sword();
                    }
                    if (BKind == (byte)bKindWeapons.Blade && BType == (byte)bType.Weapon)
                    {
                        b = new Blade();
                    }
                    if (BKind == (byte)bKindWeapons.Fan && BType == (byte)bType.Weapon)
                    {
                        b = new Fan();
                    }
                    if (BKind == (byte)bKindWeapons.Brush && BType == (byte)bType.Weapon)
                    {
                        b = new Brush();
                    }
                    if (BKind == (byte)bKindWeapons.Claw && BType == (byte)bType.Weapon)
                    {
                        b = new Claw();
                    }
                    if (BKind == (byte)bKindWeapons.Axe && BType == (byte)bType.Weapon)
                    {
                        b = new Axe();
                    }
                    if (BKind == (byte)bKindWeapons.Talon && BType == (byte)bType.Weapon)
                    {
                        b = new Talon();
                    }
                    if (BKind == (byte)bKindWeapons.Tonfa && BType == (byte)bType.Weapon)
                    {
                        b = new Tonfa();
                    }
                    if (BKind == (byte)bKindWeapons.Hammer && BType == (byte)bType.Weapon)
                    {
                        b = new Hammer();
                    }
                    if (BKind == (byte)bKindArmors.SwordMan && BType == (byte)bType.Clothes)
                    {
                        b = new Clothes();
                    }
                    if (BKind == (byte)bKindArmors.Mage && BType == (byte)bType.Clothes)
                    {
                        b = new Dress();
                    }
                    if (BKind == (byte)bKindArmors.Warrior && BType == (byte)bType.Clothes)
                    {
                        b = new Armor();
                    }
                    if (BKind == (byte)bKindArmors.GhostFighter && BType == (byte)bType.Clothes)
                    {
                        b = new LeatherClothes();
                    }
                    if (BKind == (byte)bKindHats.SwordMan && BType == (byte)bType.Hat)
                    {
                        b = new Hood();
                    }
                    if (BKind == (byte)bKindHats.Mage && BType == (byte)bType.Hat)
                    {
                        b = new Tiara();
                    }
                    if (BKind == (byte)bKindHats.Warrior && BType == (byte)bType.Hat)
                    {
                        b = new Helmet();
                    }
                    if (BKind == (byte)bKindHats.GhostFighter && BType == (byte)bType.Hat)
                    {
                        b = new Hat();
                    }
                    if (BKind == (byte)bKindHats.SwordMan && BType == (byte)bType.Shoes)
                    {
                        b = new SmBoots();
                    }
                    if (BKind == (byte)bKindHats.Mage && BType == (byte)bType.Shoes)
                    {
                        b = new MageBoots();
                    }
                    if (BKind == (byte)bKindHats.Warrior && BType == (byte)bType.Shoes)
                    {
                        b = new WarriorShoes();
                    }
                    if (BKind == (byte)bKindHats.GhostFighter && BType == (byte)bType.Shoes)
                    {
                        b = new GhostFighterShoes();
                    }
                    if (BKind == 0 && BType == (byte)bType.Ring)
                    {
                        b = new Ring();
                    }
                    if (BKind == 0 && BType == (byte)bType.Necklace)
                    {
                        b = new Necklace();
                    }
                    if (BType == (byte)bType.Cape)
                    {
                        b = new Cape();
                        Cape c = b as Cape;
                        c.MaxPolishImbueTries = reader.GetInt16(ordinalITEM_MAXPOLISHTRIES);
                    }



                    Equipment e = b as Equipment;
                    e.RequiredLevel     = reader.GetInt16(ordinalITEM_LEVEL);
                    e.RequiredDexterity = reader.GetInt16(ordinalITEM_DEX);
                    e.RequiredStrength  = reader.GetInt16(ordinalITEM_STR);
                    e.RequiredStamina   = reader.GetInt16(ordinalITEM_STA);
                    e.RequiredEnergy    = reader.GetInt16(ordinalITEM_ENE);
                    e.Durability        = reader.GetInt32(ordinalITEM_DURABILITY);
                    e.MaxDurability     = e.Durability;
                    e.Damage            = reader.GetInt16(ordinalITEM_DAMAGE);
                    e.Defence           = reader.GetInt16(ordinalITEM_DEFENCE);
                    e.AttackRating      = reader.GetInt16(ordinalITEM_ATTACKRATING);
                    e.AttackSpeed       = reader.GetInt16(ordinalITEM_ATTACKSPEED);
                    e.AttackRange       = reader.GetInt16(ordinalITEM_ATTACKRANGE);
                    e.IncMaxLife        = reader.GetInt16(ordinalITEM_INCMAXLIFE);
                    e.IncMaxMana        = reader.GetInt16(ordinalITEM_INCMAXMANA);
                    e.IncLifeRegen      = reader.GetInt16(ordinalITEM_LIFEREGEN);
                    e.IncManaRegen      = reader.GetInt16(ordinalITEM_MANAREGEN);
                    e.Critical          = reader.GetInt16(ordinalITEM_CRITICAL);
                    e.MaxImbueTries     = reader.GetByte(ordinalITEM_MAXIMBUETRIES);
                }

                if (BType == (byte)bType.ImbueItem)
                {
                    if (BKind == (byte)bKindStones.Black)
                    {
                        b = new Black();
                    }
                    if (BKind == (byte)bKindStones.White)
                    {
                        b = new White();
                    }
                    if (BKind == (byte)bKindStones.Red)
                    {
                        b = new Red();
                    }
                    if (BKind == (byte)bKindStones.Dragon)
                    {
                        b = new Dragon();
                    }

                    ImbueItem im = b as ImbueItem;
                    im.ImbueChance   = reader.GetInt16(ordinalITEM_IMBUERATE);
                    im.IncreaseValue = reader.GetInt16(ordinalITEM_IMBUEINCREASE);
                }

                if (BType == (byte)bType.Potion)
                {
                    if (BKind == (byte)bKindPotions.Normal)
                    {
                        b = new Potion();
                    }
                    if (BKind == (byte)bKindPotions.Elixir)
                    {
                        b = new Elixir();
                    }

                    PotionItem pot = b as PotionItem;
                    pot.HealHp   = reader.GetInt16(ordinalITEM_INCMAXLIFE);
                    pot.HealMana = reader.GetInt16(ordinalITEM_INCMAXMANA);
                }
                if (BType == (byte)bType.Book)
                {
                    if (BKind == (byte)bKindBooks.SoftBook)
                    {
                        b = new SoftBook();
                    }
                    if (BKind == (byte)bKindBooks.HardBook)
                    {
                        b = new HardBook();
                    }

                    BookItem book = b as BookItem;
                    book.RequiredClass = reader.GetByte(ordinalITEM_CLASS);
                    book.RequiredLevel = reader.GetInt16(ordinalITEM_LEVEL);
                    book.SkillID       = reader.GetInt32(ordinalITEM_BOOKSKILLID);
                    book.SkillLevel    = reader.GetByte(ordinalITEM_BOOKSKILLLEVEL);
                    book.SkillData     = reader.GetInt32(ordinalITEM_BOOKSKILLDATA);
                }
                if (BType == (byte)bType.Bead)
                {
                    if (BKind == (byte)bKindBeads.Normal)
                    {
                        b = new Bead();
                    }
                    BeadItem bead = b as BeadItem;
                    bead.ToMapID = reader.GetInt32(ordinalITEM_TOMAPID);
                }

                b.ReferenceID   = reader.GetInt16(ordinalITEM_REFERENCEID);
                b.VisualID      = reader.GetInt16(ordinalITEM_VISUALID);
                b.Bag           = reader.GetByte(ordinalITEM_BAG);
                b.Slot          = reader.GetByte(ordinalITEM_SLOT);
                b.bType         = reader.GetByte(ordinalITEM_BTYPE);
                b.bKind         = reader.GetByte(ordinalITEM_BKIND);
                b.RequiredClass = reader.GetByte(ordinalITEM_CLASS);
                b.Amount        = reader.GetInt16(ordinalITEM_AMOUNT);
                b.SizeX         = reader.GetByte(ordinalITEM_SIZEX);
                b.SizeY         = reader.GetByte(ordinalITEM_SIZEY);
                b.Price         = reader.GetInt32(ordinalITEM_PRICE);

                items.Add(b);
            }

            reader.Close();
            _db.Close();

            return(items);
        }
Exemple #55
0
        // Add the item to the drop list
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            int dropChance;

            int.TryParse(textBoxItemOdds.Text, out dropChance);

            if (dropChance < 1)
            {
                dropChance = 1;
            }

            string quest = QuestOnlyCheckBox.Checked ? "Q" : "";

            try
            {
                switch (tabControlSeperateItems.SelectedTab.Tag.ToString())
                {
                case "Weapon":
                    Weapon.Add(new DropItem {
                        Name = listBoxWeapon.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Armour":
                    Armour.Add(new DropItem {
                        Name = listBoxArmour.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Helmet":
                    Helmet.Add(new DropItem {
                        Name = listBoxHelmet.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Necklace":
                    Necklace.Add(new DropItem {
                        Name = listBoxNecklace.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Bracelet":
                    Bracelet.Add(new DropItem {
                        Name = listBoxBracelet.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Ring":
                    Ring.Add(new DropItem {
                        Name = listBoxRing.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Amulet":
                    Amulet.Add(new DropItem {
                        Name = listBoxAmulet.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Belt":
                    Belt.Add(new DropItem {
                        Name = listBoxBelt.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Boots":
                    Boot.Add(new DropItem {
                        Name = listBoxBoot.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Stone":
                    Stone.Add(new DropItem {
                        Name = listBoxStone.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Torch":
                    Torch.Add(new DropItem {
                        Name = listBoxTorch.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Potion":
                    Potion.Add(new DropItem {
                        Name = listBoxPotion.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Ore":
                    Ore.Add(new DropItem {
                        Name = listBoxOre.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Meat":
                    Meat.Add(new DropItem {
                        Name = listBoxMeat.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "CraftingMaterial":
                    CraftingMaterial.Add(new DropItem {
                        Name = listBoxCraftingMaterial.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance)
                    });
                    break;

                case "Scroll":
                    Scrolls.Add(new DropItem {
                        Name = listBoxScroll.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Gem":
                    Gem.Add(new DropItem {
                        Name = listBoxGem.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Mount":
                    Mount.Add(new DropItem {
                        Name = listBoxMount.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Book":
                    Book.Add(new DropItem {
                        Name = listBoxBook.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Nothing":
                    Nothing.Add(new DropItem {
                        Name = listBoxNothing.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Script":
                    Script.Add(new DropItem {
                        Name = listBoxScript.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Reins":
                    Reins.Add(new DropItem {
                        Name = listBoxReins.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Bells":
                    Bells.Add(new DropItem {
                        Name = listBoxBells.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Saddle":
                    Saddle.Add(new DropItem {
                        Name = listBoxSaddle.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Ribbon":
                    Ribbon.Add(new DropItem {
                        Name = listBoxRibbon.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Mask":
                    Mask.Add(new DropItem {
                        Name = listBoxMask.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Food":
                    Food.Add(new DropItem {
                        Name = listBoxFood.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Hook":
                    Hook.Add(new DropItem {
                        Name = listBoxHook.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Float":
                    Float.Add(new DropItem {
                        Name = listBoxFloat.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Bait":
                    Bait.Add(new DropItem {
                        Name = listBoxBait.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Finder":
                    Finder.Add(new DropItem {
                        Name = listBoxFinder.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Reel":
                    Reel.Add(new DropItem {
                        Name = listBoxReel.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Fish":
                    Fish.Add(new DropItem {
                        Name = listBoxFish.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Quest":
                    Quest.Add(new DropItem {
                        Name = listBoxQuest.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Awakening":
                    Awakening.Add(new DropItem {
                        Name = listBoxAwakening.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Pets":
                    Pets.Add(new DropItem {
                        Name = listBoxPets.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Transform":
                    Transform.Add(new DropItem {
                        Name = listBoxTransform.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;
                }

                UpdateDropFile();
            }
            catch
            {
                //No item selected when trying to add an item to the drop
            }
        }
Exemple #56
0
        public override void receiveLeftClick(int x, int y, bool playSound = true)
        {
            foreach (ClickableComponent c in equipmentIcons)
            {
                if (c.containsPoint(x, y))
                {
                    bool heldItemWasNull = !checkHeldItem();
                    switch (c.name)
                    {
                    case "Hat":
                        if (checkHeldItem((Item i) => i == null || i is Hat || i is Pan))
                        {
                            Hat  tmp       = (Game1.player.CursorSlotItem is Pan) ? new Hat(71) : ((Hat)takeHeldItem());
                            Item heldItem2 = (Hat)Game1.player.hat;
                            heldItem2 = Utility.PerformSpecialItemGrabReplacement(heldItem2);
                            setHeldItem(heldItem2);
                            Game1.player.hat.Value = tmp;
                            if (Game1.player.hat.Value != null)
                            {
                                Game1.playSound("grassyStep");
                            }
                            else if (checkHeldItem())
                            {
                                Game1.playSound("dwop");
                            }
                        }
                        break;

                    case "Left Ring":
                        if (checkHeldItem((Item i) => i == null || i is Ring))
                        {
                            Ring tmp2 = (Ring)takeHeldItem();
                            if (Game1.player.leftRing.Value != null)
                            {
                                Game1.player.leftRing.Value.onUnequip(Game1.player, Game1.currentLocation);
                            }
                            setHeldItem((Ring)Game1.player.leftRing);
                            Game1.player.leftRing.Value = tmp2;
                            if (Game1.player.leftRing.Value != null)
                            {
                                Game1.player.leftRing.Value.onEquip(Game1.player, Game1.currentLocation);
                                Game1.playSound("crit");
                            }
                            else if (checkHeldItem())
                            {
                                Game1.playSound("dwop");
                            }
                        }
                        break;

                    case "Right Ring":
                        if (checkHeldItem((Item i) => i == null || i is Ring))
                        {
                            Ring tmp3 = (Ring)takeHeldItem();
                            if (Game1.player.rightRing.Value != null)
                            {
                                Game1.player.rightRing.Value.onUnequip(Game1.player, Game1.currentLocation);
                            }
                            setHeldItem((Ring)Game1.player.rightRing);
                            Game1.player.rightRing.Value = tmp3;
                            if (Game1.player.rightRing.Value != null)
                            {
                                Game1.player.rightRing.Value.onEquip(Game1.player, Game1.currentLocation);
                                Game1.playSound("crit");
                            }
                            else if (checkHeldItem())
                            {
                                Game1.playSound("dwop");
                            }
                        }
                        break;

                    case "Boots":
                        if (checkHeldItem((Item i) => i == null || i is Boots))
                        {
                            Boots tmp4 = (Boots)takeHeldItem();
                            if (Game1.player.boots.Value != null)
                            {
                                Game1.player.boots.Value.onUnequip();
                            }
                            setHeldItem((Boots)Game1.player.boots);
                            Game1.player.boots.Value = tmp4;
                            if (Game1.player.boots.Value != null)
                            {
                                Game1.player.boots.Value.onEquip();
                                Game1.playSound("sandyStep");
                                DelayedAction.playSoundAfterDelay("sandyStep", 150);
                            }
                            else if (checkHeldItem())
                            {
                                Game1.playSound("dwop");
                            }
                        }
                        break;

                    case "Shirt":
                        if (checkHeldItem((Item i) => i == null || (i is Clothing && (i as Clothing).clothesType.Value == 0)))
                        {
                            Clothing tmp5      = (Clothing)takeHeldItem();
                            Item     heldItem4 = (Clothing)Game1.player.shirtItem;
                            heldItem4 = Utility.PerformSpecialItemGrabReplacement(heldItem4);
                            setHeldItem(heldItem4);
                            Game1.player.shirtItem.Value = tmp5;
                            if (Game1.player.shirtItem.Value != null)
                            {
                                Game1.playSound("sandyStep");
                            }
                            else if (checkHeldItem())
                            {
                                Game1.playSound("dwop");
                            }
                        }
                        break;

                    case "Pants":
                        if (checkHeldItem((Item i) => i == null || (i is Clothing && (i as Clothing).clothesType.Value == 1) || (i is Object && (int)i.parentSheetIndex == 71)))
                        {
                            Clothing tmp6      = (Game1.player.CursorSlotItem is Object && (int)Game1.player.CursorSlotItem.parentSheetIndex == 71) ? new Clothing(15) : ((Clothing)takeHeldItem());
                            Item     heldItem6 = (Clothing)Game1.player.pantsItem;
                            heldItem6 = Utility.PerformSpecialItemGrabReplacement(heldItem6);
                            setHeldItem(heldItem6);
                            Game1.player.pantsItem.Value = tmp6;
                            if (Game1.player.pantsItem.Value != null)
                            {
                                Game1.playSound("sandyStep");
                            }
                            else if (checkHeldItem())
                            {
                                Game1.playSound("dwop");
                            }
                        }
                        break;
                    }
                    if (heldItemWasNull && checkHeldItem() && Game1.oldKBState.IsKeyDown(Keys.LeftShift))
                    {
                        int l;
                        for (l = 0; l < Game1.player.items.Count; l++)
                        {
                            if (Game1.player.items[l] == null || checkHeldItem((Item item) => Game1.player.items[l].canStackWith(item)))
                            {
                                if (Game1.player.CurrentToolIndex == l && checkHeldItem())
                                {
                                    Game1.player.CursorSlotItem.actionWhenBeingHeld(Game1.player);
                                }
                                setHeldItem(Utility.addItemToInventory(takeHeldItem(), l, inventory.actualInventory));
                                if (Game1.player.CurrentToolIndex == l && checkHeldItem())
                                {
                                    Game1.player.CursorSlotItem.actionWhenStopBeingHeld(Game1.player);
                                }
                                Game1.playSound("stoneStep");
                                return;
                            }
                        }
                    }
                }
            }
            setHeldItem(inventory.leftClick(x, y, takeHeldItem(), !Game1.oldKBState.IsKeyDown(Keys.LeftShift)));
            if (checkHeldItem((Item i) => i != null && Utility.IsNormalObjectAtParentSheetIndex(i, 434)))
            {
                Game1.playSound("smallSelect");
                Game1.player.eatObject(takeHeldItem() as Object, overrideFullness: true);
                Game1.exitActiveMenu();
            }
            else if (checkHeldItem() && Game1.oldKBState.IsKeyDown(Keys.LeftShift))
            {
                if (checkHeldItem((Item i) => i is Ring))
                {
                    if (Game1.player.leftRing.Value == null)
                    {
                        Game1.player.leftRing.Value = (takeHeldItem() as Ring);
                        Game1.player.leftRing.Value.onEquip(Game1.player, Game1.currentLocation);
                        Game1.playSound("crit");
                        return;
                    }
                    if (Game1.player.rightRing.Value == null)
                    {
                        Game1.player.rightRing.Value = (takeHeldItem() as Ring);
                        Game1.player.rightRing.Value.onEquip(Game1.player, Game1.currentLocation);
                        Game1.playSound("crit");
                        return;
                    }
                }
                else if (checkHeldItem((Item i) => i is Hat))
                {
                    if (Game1.player.hat.Value == null)
                    {
                        Game1.player.hat.Value = (takeHeldItem() as Hat);
                        Game1.playSound("grassyStep");
                        return;
                    }
                }
                else if (checkHeldItem((Item i) => i is Boots))
                {
                    if (Game1.player.boots.Value == null)
                    {
                        Game1.player.boots.Value = (takeHeldItem() as Boots);
                        Game1.player.boots.Value.onEquip();
                        Game1.playSound("sandyStep");
                        DelayedAction.playSoundAfterDelay("sandyStep", 150);
                        return;
                    }
                }
                else if (checkHeldItem((Item i) => i is Clothing && (i as Clothing).clothesType.Value == 0))
                {
                    if (Game1.player.shirtItem.Value == null)
                    {
                        Game1.player.shirtItem.Value = (takeHeldItem() as Clothing);
                        Game1.playSound("sandyStep");
                        DelayedAction.playSoundAfterDelay("sandyStep", 150);
                        return;
                    }
                }
                else if (checkHeldItem((Item i) => i is Clothing && (i as Clothing).clothesType.Value == 1) && Game1.player.pantsItem.Value == null)
                {
                    Game1.player.pantsItem.Value = (takeHeldItem() as Clothing);
                    Game1.playSound("sandyStep");
                    DelayedAction.playSoundAfterDelay("sandyStep", 150);
                    return;
                }
                if (inventory.getInventoryPositionOfClick(x, y) >= 12)
                {
                    int k;
                    for (k = 0; k < 12; k++)
                    {
                        if (Game1.player.items[k] == null || checkHeldItem((Item item) => Game1.player.items[k].canStackWith(item)))
                        {
                            if (Game1.player.CurrentToolIndex == k && checkHeldItem())
                            {
                                Game1.player.CursorSlotItem.actionWhenBeingHeld(Game1.player);
                            }
                            setHeldItem(Utility.addItemToInventory(takeHeldItem(), k, inventory.actualInventory));
                            if (checkHeldItem())
                            {
                                Game1.player.CursorSlotItem.actionWhenStopBeingHeld(Game1.player);
                            }
                            Game1.playSound("stoneStep");
                            return;
                        }
                    }
                }
                else if (inventory.getInventoryPositionOfClick(x, y) < 12)
                {
                    int j;
                    for (j = 12; j < Game1.player.items.Count; j++)
                    {
                        if (Game1.player.items[j] == null || checkHeldItem((Item item) => Game1.player.items[j].canStackWith(item)))
                        {
                            if (Game1.player.CurrentToolIndex == j && checkHeldItem())
                            {
                                Game1.player.CursorSlotItem.actionWhenBeingHeld(Game1.player);
                            }
                            setHeldItem(Utility.addItemToInventory(takeHeldItem(), j, inventory.actualInventory));
                            if (checkHeldItem())
                            {
                                Game1.player.CursorSlotItem.actionWhenStopBeingHeld(Game1.player);
                            }
                            Game1.playSound("stoneStep");
                            return;
                        }
                    }
                }
            }
            if (portrait.containsPoint(x, y))
            {
                portrait.name = (portrait.name.Equals("32") ? "8" : "32");
            }
            if (trashCan.containsPoint(x, y) && checkHeldItem((Item i) => i?.canBeTrashed() ?? false))
            {
                Utility.trashItem(takeHeldItem());
                if (Game1.options.SnappyMenus)
                {
                    snapCursorToCurrentSnappedComponent();
                }
            }
            else if (!isWithinBounds(x, y) && checkHeldItem((Item i) => i?.canBeTrashed() ?? false))
            {
                Game1.playSound("throwDownITem");
                Game1.createItemDebris(takeHeldItem(), Game1.player.getStandingPosition(), Game1.player.FacingDirection).DroppedByPlayerID.Value = Game1.player.UniqueMultiplayerID;
            }
            if (organizeButton != null && organizeButton.containsPoint(x, y))
            {
                ItemGrabMenu.organizeItemsInList(Game1.player.items);
                Game1.playSound("Ship");
            }
            if (junimoNoteIcon != null && junimoNoteIcon.containsPoint(x, y) && readyToClose())
            {
                Game1.activeClickableMenu = new JunimoNoteMenu(fromGameMenu: true);
            }
        }
Exemple #57
0
        // Load the monster.txt drop file.
        private void LoadDropFile(bool edit)
        {
            var lines = (edit == false) ? File.ReadAllLines(Path.Combine(Settings.DropPath, String.Format("{0}.txt", listBoxMonsters.SelectedItem))) : textBoxDropList.Lines;

            for (int i = 0; i < lines.Length; i++)
            {
                if (lines[i].StartsWith(";Gold"))
                {
                    if (lines[i + 1].StartsWith("1/"))
                    {
                        var workingLine = lines[i + 1].Split(' ');
                        GoldOdds = workingLine[0].Remove(0, 2);
                        Gold     = workingLine[2];
                        break;
                    }
                    else
                    {
                        GoldOdds = "0";
                        Gold     = "0";
                    }
                }
            }

            string[] Headers = new string[37]
            {
                ";Weapons",
                ";Armours",
                ";Helmets",
                ";Necklaces",
                ";Bracelets",
                ";Rings",
                ";Amulets",
                ";Belts",
                ";Boots",
                ";Stones",
                ";Torches",
                ";Potions",
                ";Ores",
                ";Meat",
                ";Crafting Materials",
                ";Scrolls",
                ";Gems",
                ";Mount",
                ";Books",
                ";Nothing",
                ";Script",
                ";Reins",
                ";Bells",
                ";Saddle",
                ";Ribbon",
                ";Mask",
                ";Food",
                ";Hook",
                ";Float",
                ";Bait",
                ";Finder",
                ";Reel",
                ";Fish",
                ";Quest",
                ";Awakening",
                ";Pets",
                ";Transform"
            };

            for (int i = 0; i < Headers.Length; i++)
            {
                for (int j = 0; j < lines.Length; j++)
                {
                    if (lines[j].StartsWith(Headers[i]))
                    {
                        for (int k = j + 1; k < lines.Length; k++)
                        {
                            if (lines[k].StartsWith(";"))
                            {
                                break;
                            }

                            var workingLine = lines[k].Split(' ');
                            if (workingLine.Length < 2)
                            {
                                continue;
                            }

                            var quest = "";

                            if (workingLine.Length > 2 && workingLine[2] == "Q")
                            {
                                quest = workingLine[2];
                            }

                            DropItem newDropItem = new DropItem {
                                Odds = workingLine[0], Name = workingLine[1], Quest = quest
                            };
                            switch (i)
                            {
                            case 0:
                                Weapon.Add(newDropItem);
                                break;

                            case 1:
                                Armour.Add(newDropItem);
                                break;

                            case 2:
                                Helmet.Add(newDropItem);
                                break;

                            case 3:
                                Necklace.Add(newDropItem);
                                break;

                            case 4:
                                Bracelet.Add(newDropItem);
                                break;

                            case 5:
                                Ring.Add(newDropItem);
                                break;

                            case 6:
                                Amulet.Add(newDropItem);
                                break;

                            case 7:
                                Belt.Add(newDropItem);
                                break;

                            case 8:
                                Boot.Add(newDropItem);
                                break;

                            case 9:
                                Stone.Add(newDropItem);
                                break;

                            case 10:
                                Torch.Add(newDropItem);
                                break;

                            case 11:
                                Potion.Add(newDropItem);
                                break;

                            case 12:
                                Ore.Add(newDropItem);
                                break;

                            case 13:
                                Meat.Add(newDropItem);
                                break;

                            case 14:
                                CraftingMaterial.Add(newDropItem);
                                break;

                            case 15:
                                Scrolls.Add(newDropItem);
                                break;

                            case 16:
                                Gem.Add(newDropItem);
                                break;

                            case 17:
                                Mount.Add(newDropItem);
                                break;

                            case 18:
                                Book.Add(newDropItem);
                                break;

                            case 19:
                                Nothing.Add(newDropItem);
                                break;

                            case 20:
                                Script.Add(newDropItem);
                                break;

                            case 21:
                                Reins.Add(newDropItem);
                                break;

                            case 22:
                                Bells.Add(newDropItem);
                                break;

                            case 23:
                                Saddle.Add(newDropItem);
                                break;

                            case 24:
                                Ribbon.Add(newDropItem);
                                break;

                            case 25:
                                Mask.Add(newDropItem);
                                break;

                            case 26:
                                Food.Add(newDropItem);
                                break;

                            case 27:
                                Hook.Add(newDropItem);
                                break;

                            case 28:
                                Float.Add(newDropItem);
                                break;

                            case 29:
                                Bait.Add(newDropItem);
                                break;

                            case 30:
                                Finder.Add(newDropItem);
                                break;

                            case 31:
                                Reel.Add(newDropItem);
                                break;

                            case 32:
                                Fish.Add(newDropItem);
                                break;

                            case 33:
                                Quest.Add(newDropItem);
                                break;

                            case 34:
                                Awakening.Add(newDropItem);
                                break;

                            case 35:
                                Pets.Add(newDropItem);
                                break;

                            case 36:
                                Transform.Add(newDropItem);
                                break;

                            default:
                                break;
                            }
                        }
                    }
                }
            }
        }
Exemple #58
0
        public MatchWrestler InstantiateWrester(WrestlerData wrestlerData, int teamNumber, int positionInTeam,
                                                Match matchManager, InMatchWrestlingTargetDeterminator targetDeterminator, Ring ring)
        {
            MatchWrestler matchWrestler = Instantiate(wrestlerPrefab);

            RingPosition startingPosition = null;

            switch (teamNumber)
            {
            case 0:
                startingPosition = GetStartingRingPosition(_teamOne, positionInTeam);
                break;

            case 1:
                startingPosition = GetStartingRingPosition(_teamTwo, positionInTeam);
                break;

            case 2:
                startingPosition = GetStartingRingPosition(_teamThree, positionInTeam);
                break;

            case 3:
                startingPosition = GetStartingRingPosition(_teamFour, positionInTeam);
                break;

            default:
                break;
            }

            //TODO: Set wrestlers position in the world here.

            matchWrestler.InitializeWrestler(matchManager, wrestlerData, targetDeterminator, ring, startingPosition);
            ;
            return(matchWrestler);
        }
 /// <summary>
 /// Initializes the strategies with the specified nodes and cluster configuration
 /// </summary>
 /// <param name="nodes"> The nodes. </param>
 /// <param name="config"> The config. </param>
 public RandomConnectionStrategy(Ring nodes, CqlConnectionStringBuilder config)
 {
     _nodes = nodes;
     _config = config;
     _rnd = new Random((int)DateTime.UtcNow.Ticks);
 }
Exemple #60
0
        /**
         * Gives the player the ring of yoba.
         */
        private void GiveYobaRing()
        {
            Item ring = new Ring(524); // ID of ring of yoba

            Game1.player.addItemByMenuIfNecessary(ring);
        }