Inheritance: MonoBehaviour
Esempio n. 1
0
    private Prop CreatePropInfo(FileInfo file)
    {
        string[] cfgData = File.ReadAllLines(file.FullName);

        if (cfgData == null || cfgData.Length == 0)
        {
            Debug.Log("Config data for prop '" + file.Directory.Name + "' is null or has zero length");
            return null;
        }

        Prop newProp = new Prop(file.DirectoryName, file.Directory.Name);

        foreach (string cfgLine in cfgData)
        {
            string cfg = cfgLine.Trim(charTrim).ToLower();

            if (cfg.StartsWith("proxy"))
            {
                Proxy newProxy = CreateProxyInfo(file.Directory.Name, cfg);

                if (newProxy != null)
                    newProp.proxies.Add(newProxy);
            }
        }

        if (newProp.proxies.Count == 0)
        {
            Debug.Log("Config data for prop '" + file.Directory.Name + "' contains no usable proxies and is therefore invalid");
            return null;
        }

        return newProp;
    }
 public bool collidesWithProp(Prop prop,Rectangle rect)
 {
     if(prop.hitBox.Intersects(rect)){
         return true;
     }
     return false;
 }
Esempio n. 3
0
 /// <summary>
 /// Release the current prop.
 /// </summary>
 /// <returns>A reference to the released prop.</returns>
 public Prop Release()
 {
     Prop temp = this.CurrentProp;
     this.CurrentProp = null;
     this.current = null;
     return temp;
 }
	public void OnTouchGate(Creature creature, Prop gate)
	{
		if (gate.State != "closed")
			return;

		var canOpen = creature.Keywords.Has("g1_36") || creature.Titles.IsUsable(BreakerTitle);
		var saturday = (ErinnTime.Now.Month == ErinnMonth.Samhain || IsEnabled("AllWeekBreaker"));

		if (!canOpen)
		{
			Send.Notice(creature, Localization.Get("You are unable to open the gate."));
		}
		else if (!saturday)
		{
			Send.Notice(creature, Localization.Get("The gate can only be opened on Samhain."));
		}
		else
		{
			creature.Titles.Enable(BreakerTitle);

			gate.SetState("open");

			var portal = gate.Region.GetProp(a => a.Info.Id == GatePortalPropId);
			portal.Extensions.Add(new ConfirmationPropExtension("portal(45360425219915779)", L("Would you like to go to the world across the Sealed door?")));
		}
	}
Esempio n. 5
0
        //---------------------------------------------------------------------
        public override void defAllProp(Dictionary<string, string> map_param)
        {
            EffectMgr = new EffectMgr();

            mPropIsBot = defProp<bool>(map_param, "IsBot", false);
            mPropAccountId = defProp<string>(map_param, "AccountId", "");
            mPropAccountName = defProp<string>(map_param, "AccountName", "");
            mPropActorId = defProp<ulong>(map_param, "ActorId", 0);
            mPropNickName = defProp<string>(map_param, "NickName", "");
            mPropIcon = defProp<string>(map_param, "Icon", "");
            mPropIpAddress = defProp<string>(map_param, "IpAddress", "");
            mPropGender = defProp<bool>(map_param, "Gender", false);
            mPropIndividualSignature = defProp<string>(map_param, "IndividualSignature", "这家伙很懒,什么也没留下!");
            mPropLevel = defProp<int>(map_param, "Level", 1);
            mPropExperience = defProp<int>(map_param, "Experience", 0);
            PropGold = defProp<int>(map_param, "Gold", 100);
            mPropProfileSkinTableId = defProp<int>(map_param, "ProfileSkinTableId", 1);
            mPropIsVIP = defProp<bool>(map_param, "IsVIP", false);
            mPropVIPDataTime = defProp<DateTime>(map_param, "VIPDataTime", DateTime.Now);
            mPropVIPPoint = defProp<int>(map_param, "VIPPoint", 0);
            mPropGameTotal = defProp<int>(map_param, "GameTotal", 0);
            mPropGameWin = defProp<int>(map_param, "GameWin", 0);
            mPropJoinDateTime = defProp<DateTime>(map_param, "JoinDataTime", DateTime.Now);
            mPropLastOnlineDateTime = defProp<DateTime>(map_param, "LastOnlineDateTime", DateTime.Now);
            mPropIsAFK = defProp<bool>(map_param, "IsAFK", false);
        }
Esempio n. 6
0
        void FixedUpdate()
        {
            fixedUpdateCalled = true;

            if (currentProp == lastProp) return;

            // Dropping current prop
            if (currentProp == null) {
                puppetMaster.RemoveMuscleRecursive(lastProp.muscle, true);
                lastProp.Drop();
            }

            // Picking up to an empty slot
            if (lastProp == null) {
                AttachProp(currentProp);
            }

            // Switching props
            if (lastProp != null && currentProp != null) {
                puppetMaster.RemoveMuscleRecursive(lastProp.muscle, true);
                AttachProp(currentProp);
            }

            lastProp = currentProp;
        }
 public bool collidesWithProp(Prop prop, Point point)
 {
     if (prop.hitBox.Contains(point))
     {
         return true;
     }
     return false;
 }
Esempio n. 8
0
        public static Prop CreateWoodWall()
        {
            Prop woodWall = new Prop("wood_wall_bmp");
            woodWall.Passable = false;
            woodWall.Durability = 50;

            return woodWall;
        }
Esempio n. 9
0
        public Prop<string> mPropPrefab; // Prefab

        #endregion Fields

        #region Methods

        //---------------------------------------------------------------------
        public override void defAllProp(Dictionary<string, string> map_param)
        {
            mPropPlayerTableId = defProp<int>(map_param, "PlayerTableId", 1);
            mPropNickName = defProp<string>(map_param, "NickName", "");
            mPropIcon = defProp<string>(map_param, "Icon", "");
            mPropPrefab = defProp<string>(map_param, "Prefab", "");
            mPropLevel = defProp<int>(map_param, "Level", 1);
        }
Esempio n. 10
0
        public void PropMatches_TakesSizeIntoAccount()
        {
            var prop1 = new Prop { ColumnName = "Col", SqlDbType = SqlDbType.VarChar, Size = "100" };
            var prop2 = new Prop { ColumnName = "Col", SqlDbType = SqlDbType.VarChar, Size = "101" };

            var matches = prop1.Matches(prop2);

            Assert.IsFalse(matches);
        }
Esempio n. 11
0
        public static DestroyPropEvent CreateDestroyPropEvent(Prop nProp)
        {
            DestroyPropEvent dEvent = new DestroyPropEvent(nProp);

            dEvent.CreateTime = Game.TurnsPassed;
            dEvent.ActivateTime = Game.TurnsPassed + 0;

            return dEvent;
        }
Esempio n. 12
0
    public override bool Check(Creature creature, Prop prop)
    {
        return false;

        // Wand
        if (creature.RightHand != null && creature.RightHand.Info.Id >= 40038 && creature.RightHand.Info.Id <= 40041)
            return true;

        return false;
    }
Esempio n. 13
0
    /// <summary>
    /// Attach the given prop. If a prop already exists, it is replaced.
    /// </summary>
    public void Attach(Prop prop)
    {
        this.CurrentProp = prop;
        this.current = this.transform;

        foreach (PropAttachment attachment in this.Attachments)
        {
            if (prop.PropType == attachment.PropType)
                this.current = attachment.SnapPoint;
        }
    }
Esempio n. 14
0
        public static AttackPropEvent CreateAttackPropEvent(Creature nAtt, Prop nDef)
        {
            AttackPropEvent aEvent = new AttackPropEvent(nAtt, nDef);

            aEvent.CreateTime = Game.TurnsPassed;
            aEvent.ActivateTime = Game.TurnsPassed + 1;

            nAtt.State = Creature.EntityState.BUSY;

            return aEvent;
        }
Esempio n. 15
0
        public Prop<int> PropGold; // 金币

        #endregion Fields

        #region Methods

        //---------------------------------------------------------------------
        public override void defAllProp(Dictionary<string, string> map_param)
        {
            PropActorIdInDesktop = defProp<byte>(map_param, "PropActorIdInDesktop", 0, false);
            mPropActorId = defProp<ulong>(map_param, "ActorId", 0, false);
            mPropIsBot = defProp<bool>(map_param, "IsBot", false);
            mPropNickName = defProp<string>(map_param, "NickName", "");
            mPropIcon = defProp<string>(map_param, "Icon", "");
            mPropIpAddress = defProp<string>(map_param, "IpAddress", "");
            PropGold = defProp<int>(map_param, "Gold", 0);
            mPropCurrentGiftEtGuid = defProp<string>(map_param, "CurrentGiftEtGuid", "");
            mPropWaitWhileTime = defProp<float>(map_param, "WaitWhileTime", 60f);
        }
Esempio n. 16
0
        private void AttachProp(Prop prop)
        {
            prop.transform.position = transform.position;
            prop.transform.rotation = transform.rotation;

            prop.PickUp(this);
            puppetMaster.AddMuscle(prop.muscle, prop.transform, connectTo, transform, prop.muscleProps);

            if (prop.additionalPin != null && prop.additionalPinTarget != null) {
                puppetMaster.AddMuscle(prop.additionalPin, prop.additionalPinTarget, prop.muscle.GetComponent<Rigidbody>(), prop.transform, new Muscle.Props(prop.additionalPinWeight, 0f, 0f, 0f, false, Muscle.Group.Prop));
            }
        }
Esempio n. 17
0
	public override void OnPropEvent(Puzzle puzzle, Prop prop)
	{
		var chest = prop as Chest;
		if (chest != null && chest.Name == "KeyChest" && !puzzle.Get("ChestOpen"))
		{
			puzzle.Set("ChestOpen", true);

			var chestPlace = puzzle.GetPlace("ChestPlace");
			chestPlace.CloseAllDoors();
			chestPlace.SpawnSingleMob("SingleMob1");
		}
	}
Esempio n. 18
0
	public override void OnPropEvent(Puzzle puzzle, Prop prop)
	{
		var Switch = prop as Switch;
		if (Switch == null)
			return;

		if (puzzle.Get("activated"))
			return;

		var lockedPlace = puzzle.GetPlace("LockedPlace");
		lockedPlace.Open();

		puzzle.Set("activated", true);
	}
	private void SpawnGate(Dungeon dungeon)
	{
		var region = dungeon.Regions.Last();
		var endLocation = dungeon.GetEndRoomCenter();
		var direction = MabiMath.DirectionToRadian(0, -1);

		var gate = new Prop(GatePropId, endLocation.RegionId, endLocation.X, endLocation.Y, direction);
		gate.Info.Color2 = 0xffffffff;
		gate.Behavior = OnTouchGate;
		region.AddProp(gate);

		var portal = new Prop(GatePortalPropId, endLocation.RegionId, endLocation.X, endLocation.Y, direction);
		portal.Behavior = OnTouchPortal;
		region.AddProp(portal);
	}
Esempio n. 20
0
	public override void OnPropEvent(Puzzle puzzle, Prop prop)
	{
		var chest = prop as LockedChest;
		if (chest == null || puzzle.Get(chest.Name + "Open") || !chest.IsOpen)
			return;

		puzzle.Set(chest.Name + "Open", true);

		if (puzzle.Get(chest.Name + "Monster"))
		{
			var place = puzzle.GetPlace("Place");
			place.CloseAllDoors();
			place.SpawnSingleMob(chest.Name + "Mob", "Mob" + puzzle.Get("MonsterI"));
			puzzle.Set("MonsterI", puzzle.Get("MonsterI") + 1);
		}
	}
	private void OnOrbHit(Creature creature, Prop prop)
	{
		if (prop.State == "off")
		{
			var hits = prop.Vars.Temp.Get("orbHit", 0) + 1;
			prop.Vars.Temp["orbHit"] = hits;

			if (hits == OrbHits)
			{
				Send.Notice(creature, L("You broke the seal and received the Black Orb Fragment!\nCollect all four to receive the Black Orb."));

				prop.SetState("on");
				new Item(FragmentId).Drop(prop.Region, prop.GetPosition(), 50);
			}
		}
	}
Esempio n. 22
0
 static void AddPropKey(string key, string value, string valid, string message, string parent)
 {
     var db = DataQuery<Prop>.Entity(a => a.PropKey == key);
     if (db == null)
     {
         var d = new Prop
         {
             PropGD = MyProp.PropID(),
             PropKey = key,
             PropValue = value,
             PropValid = valid,
             PropMessage = message,
             ParentGD = parent
         };
         DataADU<Prop>.Add(d);
     }
 }
Esempio n. 23
0
    public Prop CreatePropInfo(FileInfo file)
    {
        string[] cfgData = File.ReadAllLines(file.FullName);

        if (cfgData == null || cfgData.Length == 0)
        {
            Debug.Log("Config data for prop '" + file.Directory.Name + "' is null or has zero length");
            return null;
        }

        Prop newProp = new Prop(file.Directory.Name, file.Name, file.Directory.Name);
        bool nameSet = false;

        foreach (string cfgLine in cfgData)
        {
            string cfg = cfgLine.Trim(charTrim).ToLower();

            if (!nameSet && cfg.StartsWith("name"))
            {
                string[] nameSplit = cfgLine.Split(charDelimiters, System.StringSplitOptions.RemoveEmptyEntries);
                if (nameSplit.Length == 2)
                {
                    newProp.propName = nameSplit[1];
                    nameSet = true;
                }
            }

            if (cfg.StartsWith("proxy"))
            {
                Proxy newProxy = CreateProxyInfo(file.Directory.Name, cfg);

                if (newProxy != null)
                    newProp.proxies.Add(newProxy);
            }
        }

        if (newProp.proxies.Count == 0)
        {
            Debug.Log("Config data for prop '" + file.Directory.Name + "' contains no usable proxies and is therefore invalid");
            return null;
        }

        return newProp;
    }
Esempio n. 24
0
	public override void OnPropEvent(Puzzle puzzle, Prop prop)
	{
		var chest = prop as Chest;
		if (chest != null)
		{
			if (chest.Name == "KeyChest" && !puzzle.Get("ChestOpen"))
			{
				puzzle.Set("ChestOpen", true);

				var chestPlace = puzzle.GetPlace("ChestPlace");
				chestPlace.CloseAllDoors();

				if (Random() < 50)
					chestPlace.SpawnSingleMob("LastMob");
				else
					chestPlace.SpawnSingleMob("ChainMob1", "Mob1");
			}
		}
	}
Esempio n. 25
0
        protected string GetPointString(Prop prop, int index)
        {
            if (prop == null)
                return string.Empty;
            if (prop.BuyCondition == null)
                return string.Empty;

            if (index == -1)
            {
                if (prop.BuyCondition.TotalPoint == int.MinValue)
                    return string.Empty;
                else
                    return prop.BuyCondition.TotalPoint.ToString();
            }

            if (prop.BuyCondition.Points[index] == int.MinValue)
                return string.Empty;
            else
                return prop.BuyCondition.Points[index].ToString();
        }
	public override void OnCleared(Dungeon dungeon)
	{
		var rnd = RandomProvider.Get();
		var creators = dungeon.GetCreators();
		var count = Math.Min(7, creators.Count);

		for (int i = 0; i < count; ++i)
		{
			var member = creators[i];
			var treasureChest = new TreasureChest();

			treasureChest.AddGold(rnd.Next(320, 1280)); // Gold
			treasureChest.Add(GetRandomTreasureItem(rnd)); // Random item

			dungeon.AddChest(treasureChest);

			member.GiveItemWithEffect(Item.CreateKey(70028, "chest"));
		}

		var orb = new Prop(25032, 0, 0, 0, 0);
		orb.SetState("off");
		orb.Behavior = OnOrbHit;
		dungeon.AddChest(orb);
	}
Esempio n. 27
0
	public override void OnPropEvent(Puzzle puzzle, Prop prop)
	{
		var Switch = prop as Switch;
		if (Switch == null)
			return;

		if (puzzle.Get("activated"))
			return;

		if (Switch.State == "on" && !puzzle.Get(Switch.Name + "Activated"))
		{
			puzzle.Set(Switch.Name + "Activated", true);

			var lockedPlace = puzzle.GetPlace("LockedPlace");

			if (Switch.Name == puzzle.Get("open"))
			{
				lockedPlace.Open();
				puzzle.Set("activated", true);
			}
			else
				lockedPlace.SpawnSingleMob(Switch.Name + "Mob", "Mob1");
		}
	}
Esempio n. 28
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int?id = _Request.Get <int>("id");

            m_IsEdit = id != null;

            if (m_IsEdit)
            {
                this.m_Prop = PropBO.Instance.GetPropByID(id.Value);

                this.m_PropType = PropBO.GetPropType(this.m_Prop.PropType);
            }
            else
            {
                this.m_Prop = new Prop();

                this.m_PropType = PropBO.GetPropType(_Request.Get("proptype"));
            }

            if (m_PropType == null)
            {
                ShowError("道具类型不存在");
            }

            if (_Request.IsClick("save"))
            {
                MessageDisplay md = CreateMessageDisplay(
                    "icon", "name", "description",
                    "price", "pricetype",
                    "packagesize", "totalnumber", "allowexchange",
                    "autoreplenish", "replenishnumber", "replenishtimespan"
                    );

                this.m_Prop.Icon = _Request.Get("icon");

                //默认为猪头卡的图片
                if (string.IsNullOrEmpty(this.m_Prop.Icon))
                {
                    this.m_Prop.Icon = "~/max-assets/icon-prop/4.gif";
                }

                this.m_Prop.Name = _Request.Get("name");

                if (string.IsNullOrEmpty(this.m_Prop.Name))
                {
                    md.AddError("name", "道具名称不能为空");
                }

                this.m_Prop.Description = _Request.Get("description");

                if (string.IsNullOrEmpty(this.m_Prop.Description))
                {
                    md.AddError("description", "道具描述不能为空");
                }

                int?sortOrder = _Request.Get <int>("SortOrder");

                if (sortOrder == null)
                {
                    md.AddError("SortOrder", "道具排序必须填写");
                }
                else if (sortOrder.Value < 0)
                {
                    md.AddError("SortOrder", "道具排序必须大于或等于0");
                }
                else
                {
                    this.m_Prop.SortOrder = sortOrder.Value;
                }

                int?price = _Request.Get <int>("price");

                if (price == null)
                {
                    md.AddError("price", "道具价格必须填写");
                }
                else if (price.Value <= 0)
                {
                    md.AddError("price", "道具价格必须大于0");
                }
                else
                {
                    this.m_Prop.Price = price.Value;
                }

                if (m_IsEdit == false)
                {
                    this.m_Prop.PropType = _Request.Get("proptype");
                }

                this.m_Prop.PropParam = m_PropType.GetPropParam(Request);

                int?priceType = _Request.Get <int>("pricetype");

                if (priceType == null)
                {
                    md.AddError("pricetype", "道具售价类型不能为空");
                }
                else
                {
                    this.m_Prop.PriceType = priceType.Value;
                }

                int?packageSize = _Request.Get <int>("packagesize");

                if (packageSize == null)
                {
                    md.AddError("packagesize", "道具重量必须填写");
                }
                else
                {
                    this.m_Prop.PackageSize = packageSize.Value;
                }

                int?totalNumber = _Request.Get <int>("totalnumber");

                if (totalNumber == null)
                {
                    md.AddError("totalnumber", "道具总数必须填写");
                }
                else if (totalNumber <= 0)
                {
                    md.AddError("totalnumber", "道具总数必须大于0");
                }
                else
                {
                    this.m_Prop.TotalNumber = totalNumber.Value;
                }

                bool?allowExchange = _Request.Get <bool>("allowexchange");

                if (allowExchange == null)
                {
                    md.AddError("allowexchange", "道具是否允许出售和赠送必须设置");
                }
                else
                {
                    this.m_Prop.AllowExchange = allowExchange.Value;
                }

                bool?autoReplenish = _Request.Get <bool>("autoreplenish");

                if (autoReplenish == null)
                {
                    md.AddError("autoreplenish", "道具是否自动补货必须设置");
                }
                else
                {
                    this.m_Prop.AutoReplenish = autoReplenish.Value;
                }

                int?replenishLimit = _Request.Get <int>("ReplenishLimit");

                if (replenishLimit == null)
                {
                    md.AddError("ReplenishLimit", "道具补货阀值必须设置");
                }
                else if (replenishLimit.Value < 0)
                {
                    md.AddError("ReplenishLimit", "道具补货阀值必须大于等于0");
                }
                else
                {
                    this.m_Prop.ReplenishLimit = replenishLimit.Value;
                }

                int?replenishNumber = _Request.Get <int>("replenishnumber");

                if (replenishNumber == null)
                {
                    md.AddError("replenishnumber", "道具自动补货数量必须填写");
                }
                else
                {
                    this.m_Prop.ReplenishNumber = replenishNumber.Value;
                }

                int?replenishTimespan = _Request.Get <int>("replenishtimespan");

                if (replenishTimespan == null)
                {
                    md.AddError("replenishtimespan", "道具自动补货周期必须设置");
                }
                else
                {
                    this.m_Prop.ReplenishTimeSpan = replenishTimespan.Value;
                }

                BuyPropCondition condition = new BuyPropCondition();

                this.m_Prop.BuyCondition = condition;

                condition.UserGroupIDs = StringUtil.Split2 <Guid>(_Request.Get("BuyCondition.groups", Method.Post, string.Empty));

                int?totalPoint = _Request.Get <int>("BuyCondition.totalPoint");

                if (totalPoint != null && totalPoint.Value > 0)
                {
                    condition.TotalPoint = totalPoint.Value;
                }

                UserPointCollection allPoints = AllSettings.Current.PointSettings.UserPoints;

                int[] points = new int[allPoints.Count];

                for (int i = 0; i < points.Length; i++)
                {
                    UserPoint point = allPoints[i];

                    if (point.Enable)
                    {
                        int?value = _Request.Get <int>("BuyCondition." + point.Type);

                        if (value != null)
                        {
                            points[i] = value.Value;
                        }
                        else
                        {
                            points[i] = 0;
                        }
                    }
                    else
                    {
                        points[i] = 0;
                    }
                }

                condition.Points = points;

                int?totalPosts = _Request.Get <int>("BuyCondition.totalPosts");

                if (totalPosts != null && totalPosts.Value > 0)
                {
                    condition.TotalPosts = totalPosts.Value;
                }

                int?onlineTime = _Request.Get <int>("BuyCondition.onlinetime");

                if (onlineTime != null && onlineTime.Value > 0)
                {
                    condition.OnlineTime = onlineTime.Value;
                }

                condition.ReleatedMissionIDs = StringUtil.Split2 <int>(_Request.Get("BuyCondition.releatedmissionids", Method.Post, string.Empty));

                if (md.HasAnyError())
                {
                    return;
                }

                using (ErrorScope es = new ErrorScope())
                {
                    if (m_IsEdit)
                    {
                        PropBO.Instance.UpdateProp(
                            m_Prop.PropID,
                            m_Prop.Icon,
                            m_Prop.Name,
                            price.Value,
                            priceType.Value,
                            m_Prop.PropType,
                            m_Prop.PropParam,
                            m_Prop.Description,
                            packageSize.Value,
                            totalNumber.Value,
                            allowExchange.Value,
                            autoReplenish.Value,
                            replenishNumber.Value,
                            replenishTimespan.Value,
                            replenishLimit.Value,
                            condition,
                            sortOrder.Value
                            );
                    }
                    else
                    {
                        PropBO.Instance.CreateProp(
                            m_Prop.Icon,
                            m_Prop.Name,
                            price.Value,
                            priceType.Value,
                            m_Prop.PropType,
                            m_Prop.PropParam,
                            m_Prop.Description,
                            packageSize.Value,
                            totalNumber.Value,
                            allowExchange.Value,
                            autoReplenish.Value,
                            replenishNumber.Value,
                            replenishTimespan.Value,
                            replenishLimit.Value,
                            condition,
                            sortOrder.Value
                            );
                    }

                    if (es.HasError)
                    {
                        es.CatchError <ErrorInfo>(delegate(ErrorInfo error)
                        {
                            md.AddError(error);
                        });
                    }
                    else
                    {
                        JumpTo("interactive/manage-prop.aspx?page=" + _Request.Get("page"));
                    }
                }
            }
        }
Esempio n. 29
0
 public OutputArgument(Prop initvalue) : this((object)initvalue)
 {
 }
Esempio n. 30
0
 public InputArgument(Prop value) : this((object)value)
 {
 }
Esempio n. 31
0
        /// <summary>
        /// Generates areas, incl (client) props and events.
        /// </summary>
        private void GenerateAreas()
        {
            this.Data = new RegionInfoData();

            var areaId = 2;
            var floor  = this.Floor;

            for (int x = 0; x < floor.MazeGenerator.Width; ++x)
            {
                for (int y = 0; y < floor.MazeGenerator.Height; ++y)
                {
                    var room      = floor.MazeGenerator.GetRoom(x, y);
                    var roomTrait = floor.GetRoom(x, y);

                    if (!room.Visited)
                    {
                        continue;
                    }

                    var isStart    = (roomTrait.RoomType == RoomType.Start);
                    var isEnd      = (roomTrait.RoomType == RoomType.End);
                    var isRoom     = (roomTrait.RoomType >= RoomType.Start);
                    var isBossRoom = (floor.HasBossRoom && isEnd);
                    var eventId    = 0L;

                    if (!isBossRoom)
                    {
                        var areaData = new AreaData();
                        areaData.Id   = areaId++;
                        areaData.Name = "Tile" + areaData.Id;

                        areaData.X1 = x * Dungeon.TileSize;
                        areaData.Y1 = y * Dungeon.TileSize;
                        areaData.X2 = x * Dungeon.TileSize + Dungeon.TileSize;
                        areaData.Y2 = y * Dungeon.TileSize + Dungeon.TileSize;

                        this.Data.Areas.Add(areaData);

                        var type = (isRoom ? DungeonBlockType.Room : DungeonBlockType.Alley);

                        var propEntityId = MabiId.ClientProps | ((long)this.Id << 32) | ((long)areaData.Id << 16) | 1;
                        var block        = this.Dungeon.Data.Style.Get(type, room.Directions);
                        var tileCenter   = new Point(x * Dungeon.TileSize + Dungeon.TileSize / 2, y * Dungeon.TileSize + Dungeon.TileSize / 2);

                        var prop = new Prop(propEntityId, block.PropId, this.Id, tileCenter.X, tileCenter.Y, MabiMath.DegreeToRadian(block.Rotation), 1, 0, "", "", "");
                        this.AddProp(prop);

                        // Debug
                        //foreach (var points in prop.Shapes)
                        //{
                        //	foreach (var point in points)
                        //	{
                        //		var pole = new Prop(30, this.Id, point.X, point.Y, 0, 1, 0, "", "", "");
                        //		pole.Shapes.Clear();
                        //		this.AddProp(pole);
                        //	}
                        //}

                        // TODO: This region/data stuff is a mess... create
                        //   proper classes, put them in the regions and be
                        //   done with it.

                        if (isStart || isEnd)
                        {
                            var xp = tileCenter.X;
                            var yp = tileCenter.Y;

                            if (roomTrait.DoorType[Direction.Up] >= 3000)
                            {
                                yp += 400;
                            }
                            else if (roomTrait.DoorType[Direction.Right] >= 3000)
                            {
                                xp += 400;
                            }
                            else if (roomTrait.DoorType[Direction.Down] >= 3000)
                            {
                                yp -= 400;
                            }
                            else if (roomTrait.DoorType[Direction.Left] >= 3000)
                            {
                                xp -= 400;
                            }

                            var eventData = new EventData();
                            eventData.Id   = MabiId.AreaEvents | ((long)this.Id << 32) | ((long)areaData.Id << 16) | eventId++;
                            eventData.Name = (isStart ? "Indoor_RDungeon_SB" : "Indoor_RDungeon_EB");
                            eventData.X    = xp;
                            eventData.Y    = yp;

                            var shape = new ShapeData();
                            shape.DirX1 = 1;
                            shape.DirY2 = 1;
                            shape.LenX  = 100;
                            shape.LenY  = 100;
                            shape.PosX  = xp;
                            shape.PosY  = yp;
                            eventData.Shapes.Add(shape);

                            areaData.Events.Add(eventData.Id, eventData);
                            _clientEvents.Add(eventData.Id, new ClientEvent(eventData, this.Data.Name, areaData.Name));
                        }
                    }
                    else
                    {
                        // Big main room
                        var areaData = new AreaData();
                        areaData.Id   = areaId++;
                        areaData.Name = "Tile" + areaData.Id;

                        areaData.X1 = x * Dungeon.TileSize - Dungeon.TileSize;
                        areaData.Y1 = y * Dungeon.TileSize;
                        areaData.X2 = x * Dungeon.TileSize + Dungeon.TileSize * 2;
                        areaData.Y2 = y * Dungeon.TileSize + Dungeon.TileSize * 2;

                        this.Data.Areas.Add(areaData);

                        var block        = this.Dungeon.Data.Style.Get(DungeonBlockType.BossRoom);
                        var propEntityId = MabiId.ClientProps | ((long)this.Id << 32) | ((long)areaData.Id << 16) | 1;
                        var tileCenter   = new Point(x * Dungeon.TileSize + Dungeon.TileSize / 2, y * Dungeon.TileSize + Dungeon.TileSize);

                        var prop = new Prop(propEntityId, block.PropId, this.Id, tileCenter.X, tileCenter.Y, MabiMath.DegreeToRadian(block.Rotation), 1, 0, "", "", "");
                        this.AddProp(prop);

                        // Debug
                        //foreach (var points in prop.Shapes)
                        //{
                        //	foreach (var point in points)
                        //	{
                        //		var pole = new Prop(30, this.Id, point.X, point.Y, 0, 1, 0, "", "", "");
                        //		pole.Shapes.Clear();
                        //		this.AddProp(pole);
                        //	}
                        //}

                        // Treasure room
                        areaData      = new AreaData();
                        areaData.Id   = areaId++;
                        areaData.Name = "Tile" + areaData.Id;

                        areaData.X1 = x * Dungeon.TileSize;
                        areaData.Y1 = y * Dungeon.TileSize + Dungeon.TileSize * 2;
                        areaData.X2 = x * Dungeon.TileSize + Dungeon.TileSize;
                        areaData.Y2 = y * Dungeon.TileSize + Dungeon.TileSize * 2 + Dungeon.TileSize;

                        this.Data.Areas.Add(areaData);
                    }
                }
            }
        }
Esempio n. 32
0
 private void Reset()
 {
     target = null;
 }
Esempio n. 33
0
 /// <summary>
 /// Adds prop to entries, replaces existing entries with the same
 /// prop id.
 /// </summary>
 /// <param name="prop"></param>
 public static void Add(Prop prop)
 {
     _entries.Add(prop);
 }
Esempio n. 34
0
 public void VerboseTest()
 {
     Prop.ForAll <Doc>(doc => doc.ToString() != "")
     .VerboseCheckThrowOnFailure();
 }
Esempio n. 35
0
 public Property TurnRoundMaintainsDirection()
 {
     return(Prop.ForAll <Direction, Turn.Dir>((direction, dir) => TurnRound(direction, dir) == direction));
 }
Esempio n. 36
0
        private async Task <Prop> LoadModelFileAsync(string filePath)
        {
            Prop p = null;
            XmlReaderSettings settings = new XmlReaderSettings();

            settings.Async = true;
            using (XmlReader reader = XmlReader.Create(filePath, settings))
            {
                await reader.MoveToContentAsync();

                if ("custommodel".Equals(reader.Name) && reader.HasAttributes)
                {
                    string name = reader.GetAttribute("name");
                    p           = PropModelServices.Instance().CreateProp(name);
                    p.CreatedBy = @"xModel Import";

                    //These are the size of the grid near as I can tell
                    //We will use them to gauge a scale.
                    int x, y;
                    int.TryParse(reader.GetAttribute("parm1"), out x);
                    int.TryParse(reader.GetAttribute("parm2"), out y);

                    CalculateScale(x, y);

                    int nodeSize;
                    int.TryParse(reader.GetAttribute("PixelSize"), out nodeSize);
                    string model = reader.GetAttribute("CustomModel");

                    List <SubModel> subModels = new List <SubModel>();
                    while (reader.Read())
                    {
                        if (reader.NodeType != XmlNodeType.Element)
                        {
                            continue;
                        }

                        if ("subModel".Equals(reader.Name))
                        {
                            SubModel sm = new SubModel();
                            sm.Name   = reader.GetAttribute("name");
                            sm.Layout = reader.GetAttribute("layout");
                            var type = reader.GetAttribute("type");
                            switch (type)
                            {
                            case "ranges":
                                sm.Type   = SubModelType.Ranges;
                                sm.Ranges = ParseRanges(reader.GetAttribute("line0"));
                                break;
                            }
                            subModels.Add(sm);
                        }
                        else if ("faceInfo".Equals(reader.Name))
                        {
                            var type = reader.GetAttribute("Type");
                            if (!string.IsNullOrEmpty(type) && type.Equals("NodeRange"))
                            {
                                foreach (var attribute in FaceInfo.Attributes)
                                {
                                    var range = reader.GetAttribute(attribute.Key);
                                    if (!string.IsNullOrEmpty(range))
                                    {
                                        SubModel sm = new SubModel();
                                        sm.Name     = attribute.Key;
                                        sm.Type     = SubModelType.Ranges;
                                        sm.Ranges   = ParseRanges(range);
                                        sm.FaceInfo = new FaceInfo(attribute.Value);
                                        subModels.Add(sm);
                                    }
                                }
                            }
                        }
                    }

                    var modelNodes = await CreateModelNodesAsync(model);

                    Assemble(modelNodes, subModels, nodeSize);
                }
                else
                {
                    var dependencyResolver = this.GetDependencyResolver();
                    var ms = dependencyResolver.Resolve <IMessageService>();
                    await ms.ShowErrorAsync($"Unsupported model type: {reader.Name}. \nImport only supports custom model types at this time.", "Model import error");
                }
            }

            return(p);
        }
 public void CapturingOutput_Example()
 {
     Prop.ForAll(Arb.Default.Bool(), i => i)
     .VerboseCheckThrowOnFailure(_testOutputHelper);
 }
Esempio n. 38
0
        /// <summary>
        /// Handles item burning, retruns whether it was successful.
        /// </summary>
        /// <param name="creature"></param>
        /// <param name="item"></param>
        /// <param name="campfire"></param>
        /// <param name="enchantersBurn"></param>
        public bool Burn(Creature creature, Item item, Prop campfire, bool enchantersBurn)
        {
            var skill = creature.Skills.Get(SkillId.Enchant);
            var enchantBurnSuccess = false;
            var powderBurnSuccess  = false;
            var exp = 0;

            // Enchanter's Burn
            if (enchantersBurn)
            {
                var rnd = RandomProvider.Get();

                var isEquip             = item.HasTag("/equip/");
                var hasEnchantBurnItems = (creature.Inventory.Has(51102) && creature.Inventory.Has(63016));                 // Mana Herb + Holy Water

                // Enchant burning
                if (!isEquip || !hasEnchantBurnItems)
                {
                    // Unofficial
                    Send.SystemMessage(creature, Localization.Get("You don't the necessary items."));
                    return(false);
                }

                // Get chances
                // All unofficial
                var rank          = (skill == null ? 16 : (int)skill.Info.Rank);
                var enchantChance = (skill == null ? 0 : skill.RankData.Var3);

                // Campfire r8+ bonus
                if (enchantChance > 0 && campfire.Temp.CampfireSkillRank.Rank >= SkillRank.R8)
                {
                    enchantChance += (16 - rank);
                }

                // Powder = double enchant chance, based on the Wiki saying
                // r1 doesn't guarantee getting the enchants, but it does
                // guarantee getting powder.
                var powderChance = enchantChance * 2;

                // Debug
                if (creature.Titles.SelectedTitle == TitleId.devCAT)
                {
                    Send.ServerMessage(creature, "Debug: Chance for enchant: {0:0}, chance for powder: {1:0}", enchantChance, powderChance);
                }

                // Try prefix
                if (item.OptionInfo.Prefix != 0 && rnd.Next(100) < enchantChance)
                {
                    var enchant = Item.CreateEnchant(item.OptionInfo.Prefix);
                    creature.AcquireItem(enchant);
                    enchantBurnSuccess = true;
                }

                // Try suffix
                if (item.OptionInfo.Suffix != 0 && rnd.Next(100) < enchantChance)
                {
                    var enchant = Item.CreateEnchant(item.OptionInfo.Suffix);
                    creature.AcquireItem(enchant);
                    enchantBurnSuccess = true;
                }

                // Try suffix
                if (item.OptionInfo.Prefix + item.OptionInfo.Suffix != 0 && rnd.Next(100) < powderChance)
                {
                    var powder = new Item(62003);                     // Blessed Magic Powder
                    creature.AcquireItem(powder);
                    powderBurnSuccess = true;
                }

                // Reduce items
                creature.Inventory.Remove(51102, 1);                 // Mana Herb
                creature.Inventory.Remove(63016, 1);                 // Holy Water

                // Training
                this.BurnTraining(skill, enchantBurnSuccess, powderBurnSuccess);

                // Success/Fail motion
                Send.UseMotion(creature, 14, enchantBurnSuccess ? 0 : 3);
            }

            // Seal Scroll (G1 Glas fight, drop from Gargoyles)
            if (item.HasTag("/evilscroll/55/"))
            {
                creature.Conditions.Activate(ConditionsA.Blessed, null, 60 * 1000);
                Send.Notice(creature, Localization.Get("I feel the blessing of the Goddess."));
            }
            // Other items
            else
            {
                // Add exp based on item buying price (random+unofficial)
                if (item.OptionInfo.Price > 0)
                {
                    exp = 40 + (int)(item.OptionInfo.Price / (float)item.Data.StackMax / 100f * item.Info.Amount);
                    creature.GiveExp(exp);
                }

                Send.Notice(creature, NoticeType.MiddleSystem, Localization.Get("Burning EXP {0}"), exp);
            }

            // Remove item from cursor
            creature.Inventory.Remove(item);

            Send.Effect(MabiId.Broadcast, creature, Effect.BurnItem, campfire.EntityId, enchantBurnSuccess);

            return(true);
        }
Esempio n. 39
0
	private void MoonGateBehavior(Creature creature, Prop prop)
	{
		// Get gate
		// Sanity check, technically it shouldn't ever fail, because we wouldn't
		// even get here without the gate being added in this script.
		MoonGate gate;
		if (!gates.TryGetValue(prop.EntityId, out gate))
		{
			Send.Notice(creature, Localization.Get("This moon gate is currently not operable. Please report."));
			return;
		}

		// Check state
		if (gate.Prop.State == "closed")
		{
			Log.Warning("MoonGateScript.MoonGateBehavior: Creature '{0:X16}' tried to use closed moon gate.", creature.EntityId);
			return;
		}

		if (IsEnabled("MoonTunnel") && creature.IsCharacter)
		{
			// Add keyword if creature doesn't have it yet, this "marks" the
			// moon gate as potential target in the new system, you can only
			// warp to those you have visited before.
			if (!creature.Keywords.Has(gate.Keyword))
				creature.Keywords.Give(gate.Keyword);

			// Get list of moon gates the creature can use
			var freeRoaming = (FreeRoaming || creature.Keywords.Has("freemoongate"));
			var mygates = gates.Values.Where(a => CanWarpTo(creature, a));

			SendMoonGateMap(creature, gate, mygates);
		}
		else
		{
			var origin = gate.Keyword;
			var destination = currentGateKeyword;

			UseMoonGate(creature, origin, destination);
		}
	}
Esempio n. 40
0
        protected override void OnLoad(EventArgs e)
        {
            _drawingBuffer = new Pixel[_viewPort.Width * _viewPort.Height + 1];
            _zBuffer       = new double[_viewPort.Width];

            _resourceManager = ResourceManager.Instance;
            _resourceManager.ReadResourceFile("testlevel");
            _worldMap = _resourceManager.WorldMap;
            _textures = _resourceManager.Textures;

            _player          = new Player();
            _player.Position = new Position(22, 12, -1, 0);
            _player.Movement = new Movement();
            _player.Weapon   = new Weapon(200, 200, new int[] { 15 }, _windowSize.Width - 260);
            _player.Camera   = new Camera(0, 0.66);



            _props = new List <Prop>();
            foreach (var prop in _resourceManager.Props)
            {
                var propToAdd = new Prop();
                propToAdd.Position = new Position(prop.Position.PosX, prop.Position.PosY, 0, 0);
                propToAdd.Sprite   = new Sprite(prop.Sprite.Texture);

                if (_resourceManager.AnimatedSprites.ContainsKey(Array.IndexOf(_resourceManager.Props, prop)))
                {
                    propToAdd          = new AnimatedProp();
                    propToAdd.Position = new Position(prop.Position.PosX, prop.Position.PosY, 0, 0);
                    propToAdd.Sprite   = new Sprite(prop.Sprite.Texture);
                    (propToAdd as AnimatedProp).Animation = new Animation(_resourceManager.AnimatedSprites[Array.IndexOf(_resourceManager.Props, prop)], AnimationType.Movement);
                }

                _props.Add(propToAdd);
            }

            AnimatedProp enemyProp = _props[0] as AnimatedProp;

            _props[0]          = new Enemy();
            _props[0].Position = enemyProp.Position;
            _props[0].Sprite   = enemyProp.Sprite;
            (_props[0] as Enemy).CurrentAnimation = enemyProp.Animation;

            _spriteNumber = _props.Count;

            //setup input
            Keyboard.KeyDown += new EventHandler <KeyboardKeyEventArgs>(KeyboardKeyDown);
            Keyboard.KeyUp   += new EventHandler <KeyboardKeyEventArgs>(KeyboardKeyUp);

            //setup drawing mode
            GL.MatrixMode(MatrixMode.Projection);
            GL.LoadIdentity();
            GL.Ortho(0, _windowSize.Width, _windowSize.Height, 0, 0, 1);
            GL.MatrixMode(MatrixMode.Modelview);

            //init lookup
            _distLookUp = new Dictionary <int, double>();
            for (int y = 0; y < _viewPort.Height; y++)
            {
                _distLookUp.Add(y, _viewPort.Height / (2.0 * y - _viewPort.Height));
            }
        }
        // This method can (and should) probably be merged with CallVehicleDrop to make a single CallDrop method
        // However, this works for now.
        public static void CallWeaponDrop(PickupType Weapon)
        {
            // Drop setup
            if (PlaySound)
            {
                AudioManager.PlaySound(DropSound.call);
            }
            Model CModel = new Model(Config.PlaneModel);

            if (!CModel.IsValid)
            {
                AudioManager.StopSound(DropSound.call);
                return;
            }

            // Drop continuation. This is only reached if the models were valid

            Vector3 PlanePos     = Game.Player.Character.Position + Game.Player.Character.UpVector * 80f + Game.Player.Character.ForwardVector * -35f;
            Vector3 ContainerPos = Game.Player.Character.Position + Game.Player.Character.UpVector * 75f + Game.Player.Character.ForwardVector * 10f;

            // Vehicle spawning and adjustments
            Vehicle CargoPlane = World.CreateVehicle(CModel, PlanePos);

            CargoPlane.Heading = (Game.Player.Character.Position - CargoPlane.Position).ToHeading();
            VehicleDoor CargoDoor  = CargoPlane.Doors.ToArray().FirstOrDefault(x => x.Index == VehicleDoorIndex.Trunk);
            VehicleDoor CargoDoor2 = CargoPlane.Doors.ToArray().FirstOrDefault(x => x.Index == VehicleDoorIndex.BackLeftDoor);

            if (CargoDoor != null)
            {
                CargoDoor.Open(true, true);
            }
            if (CargoDoor2 != null)
            {
                CargoDoor2.Open(true, true);
            }

            // Cargoplane pilot
            Vector3 FlyTo      = Util.LerpByDistance(CargoPlane.Position, Game.Player.Character.Position, 5000f);
            Ped     CargoPilot = CargoPlane.CreatePedOnSeat(VehicleSeat.Driver, new Model("s_m_m_pilot_02"));

            // Cargoplane AI
            Function.Call(Hash.SET_VEHICLE_FORWARD_SPEED, CargoPlane, 50f);
            Wait(500);
            Function.Call(Hash.TASK_PLANE_MISSION, CargoPilot, CargoPlane, 0, 0, FlyTo.X, FlyTo.Y, FlyTo.Z, 4, 100f, 0f, 90f, 0, 200f);

            // Container drop
            Prop Container = World.CreateProp(Globals.ContainerModel, ContainerPos, true, false);

            Container.HasGravity = true;
            Container.ApplyForce(new Vector3(0f, 0f, -35f));
            while (!Container.HasCollided)
            {
                Wait(0);
            }

            // Hit sound
            if (PlaySound)
            {
                AudioManager.StopSound(DropSound.call);
                AudioManager.PlaySound(DropSound.hit);
            }

            // Ensure the container is fully stopped
            Vector3 ContainerLastPos;

            do
            {
                ContainerLastPos = Container.Position;
                Wait(250);
            }while (Container.Position.DistanceTo(ContainerLastPos) > 0.1f);

            // Container opening
            Function.Call(Hash.REQUEST_NAMED_PTFX_ASSET, "proj_indep_firework_v2");
            Function.Call(Hash.USE_PARTICLE_FX_ASSET, "proj_indep_firework_v2");
            int ptfx = Function.Call <int>(Hash.START_PARTICLE_FX_NON_LOOPED_ON_ENTITY, "scr_firework_indep_ring_burst_rwb", Container, 0f, 0f, Container.Model.Dimensions.rearBottomLeft.X * 1f, 0f, 0f, 0f, 2f, true, true, true);

            Function.Call(Hash.SET_PARTICLE_FX_LOOPED_ALPHA, ptfx, 0.5f);
            Function.Call(Hash.SET_PARTICLE_FX_LOOPED_COLOUR, ptfx, 0.2f, 0.2f, 1f, true);
            Script.Wait(250);
            Vector3 SpawnPos = Container.Position;

            Container.Delete();

            // Weapon spawning
            Prop Drop = World.CreateAmbientPickup(Weapon, SpawnPos, new Model("ch_prop_ch_crate_full_01a"), 999);

            Drop.HasGravity   = true;
            Drop.IsPersistent = false;

            // Cleanup
            Wait(2500);
            if (!Config.FunMode)
            {
                CargoPilot.Task.ClearAll();
                CargoPlane.MarkAsNoLongerNeeded();
            }
            if (PlaySound)
            {
                AudioManager.StopSound(DropSound.hit);
            }
        }
Esempio n. 42
0
 /// <summary>
 /// Returns a warp behavior.
 /// </summary>
 /// <param name="region"></param>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <returns></returns>
 protected PropFunc PropWarp(int region, int x, int y)
 {
     return(Prop.GetWarpBehavior(region, x, y));
 }
Esempio n. 43
0
 //-------------------------------------------------------------------------
 public override void defAllProp(Dictionary <string, string> map_param)
 {
     mPropMapItemData4Db = defProp <Dictionary <byte, ItemData> >(map_param, "MapItemData", new Dictionary <byte, ItemData>());
 }
Esempio n. 44
0
 /// <summary>
 /// Removes prop from entries, returns false if the prop didn't
 /// exist.
 /// </summary>
 /// <param name="prop"></param>
 /// <returns></returns>
 public static bool Remove(Prop prop)
 {
     return(_entries.Remove(prop));
 }
Esempio n. 45
0
        public void Identity()
        {
            var sut = new Calculator();

            Prop.ForAll <int>((x) => sut.Add(x, 0) == x).QuickCheckThrowOnFailure();
        }
Esempio n. 46
0
 /// <summary>
 /// Returns a drop behavior.
 /// </summary>
 /// <param name="dropType"></param>
 /// <returns></returns>
 protected PropFunc PropDrop(int dropType)
 {
     return(Prop.GetDropBehavior(dropType));
 }
Esempio n. 47
0
        public void Associativity()
        {
            var sut = new Calculator();

            Prop.ForAll <int, int>((x, y) => sut.Add(x, y) == sut.Add(y, x)).QuickCheckThrowOnFailure();
        }
Esempio n. 48
0
        public override void OnPlayerControlTick()
        {
            if (!Host.IsServer)
            {
                return;
            }

            using (Prediction.Off())
            {
                var input    = Owner.Input;
                var startPos = Owner.EyePos;
                var dir      = Owner.EyeRot.Forward;

                var tr = Trace.Ray(startPos, startPos + dir * MaxTraceDistance)
                         .Ignore(Owner)
                         .Run();

                if (!tr.Hit || !tr.Body.IsValid() || !tr.Entity.IsValid() || tr.Entity.IsWorld)
                {
                    return;
                }

                if (Owner != tr.Entity.Owner)
                {
                    return;
                }

                if (tr.Entity.PhysicsGroup == null || tr.Entity.PhysicsGroup.BodyCount > 1)
                {
                    return;
                }

                if (tr.Entity is not Prop prop)
                {
                    return;
                }

                if (input.Pressed(InputButton.Attack1))
                {
                    if (prop.Root is not Prop rootProp)
                    {
                        return;
                    }

                    if (target == rootProp)
                    {
                        return;
                    }

                    if (!target.IsValid())
                    {
                        target = rootProp;
                    }
                    else
                    {
                        target.Weld(rootProp);
                        target = null;
                    }
                }
                else if (input.Pressed(InputButton.Attack2))
                {
                    prop.Unweld(true);

                    Reset();
                }
                else if (input.Pressed(InputButton.Reload))
                {
                    if (prop.Root is not Prop rootProp)
                    {
                        return;
                    }

                    rootProp.Unweld();

                    Reset();
                }
                else
                {
                    return;
                }

                CreateHitEffects(tr.EndPos);
            }
        }
Esempio n. 49
0
        protected override void InternalSetValue(string value)
        {
            object convertedValue = value;

            // if the property is a collection, add the item to the list
            if (IsCollection)
            {
                object propValue             = Prop.GetValue(Instance);
                var    genericCollectionType = Prop.PropertyType.GetInterface("System.Collections.Generic.ICollection`1");
                if (genericCollectionType != null)
                {
                    var converter = TypeDescriptor.GetConverter(genericCollectionType.GetGenericArguments( )[0]);
                    convertedValue = converter.ConvertFromString(value);
                }

                const BindingFlags bindingFlags = BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.Public;
                propValue.GetType().InvokeMember("Add", bindingFlags, null, propValue, new object[] { value });

                return;
            }

            // handle boolean flags, which might not have a value to convert
            // assume true unless a value is specified
            if (Prop.PropertyType == typeof(bool))
            {
                convertedValue = true;

                // If there's a value attached, convert it to a boolean
                if (!string.IsNullOrWhiteSpace(value))
                {
                    try
                    {
                        convertedValue = Convert.ToBoolean(value, CultureInfo.CurrentCulture);
                    }
                    catch (FormatException ex)
                    {
                        throw new CommandlineParseException(CultureInfo.CurrentUICulture, Resources.InvalidOptionFormat_0_1, value, ex.Message);
                    }
                }
            }
            else
            {
                if (string.IsNullOrWhiteSpace(value))
                {
                    throw new CommandlineParseException(CultureInfo.CurrentUICulture, Resources.MissingValueForOption_0, Option.Text);
                }

                if (Prop.Converter != null)
                {
                    try
                    {
                        convertedValue = Prop.Converter.ConvertFromString(value);
                    }
                    catch (NotSupportedException ex)
                    {
                        throw new CommandlineParseException(CultureInfo.CurrentUICulture, Resources.InvalidOptionFormat_0_1, value, ex.Message);
                    }
                }
            }

            Prop.SetValue(Instance, convertedValue);
        }
Esempio n. 50
0
 public void CreateProp()
 {
     Prop?.SpawnProp();
 }
Esempio n. 51
0
 public void DeleteProp()
 {
     Prop?.Delete();
 }
Esempio n. 52
0
 public void Dispose()
 {
     Prop?.Dispose();
 }
Esempio n. 53
0
 public void QuickTest()
 {
     Prop.ForAll <Doc>(doc => doc.ToString() != "")
     .QuickCheckThrowOnFailure();
 }
Esempio n. 54
0
        public void AttachEntityToEntity(IStreamedItem ent, IStreamedItem entTarget, Attachment info)
        {
            if (!ent.StreamedIn || !entTarget.StreamedIn || info == null)
            {
                return;
            }
            LogManager.DebugLog("AE2E_1");
            if (entTarget.EntityType == (byte)EntityType.Blip ||
                entTarget.EntityType == (byte)EntityType.TextLabel || // Can't attach to a blip, textlabel or marker
                entTarget.EntityType == (byte)EntityType.Marker ||
                ent.EntityType == (byte)EntityType.Marker ||
                ent.EntityType == (byte)EntityType.TextLabel || // If we're attaching blip/label/marker, UpdateAttachments will take care of it for us.
                ent.EntityType == (byte)EntityType.Blip ||
                ent.EntityType == (byte)EntityType.Pickup)      // TODO: Make pickups attachable.
            {
                return;
            }
            LogManager.DebugLog("AE2E_2");
            var handleSource = NetToEntity(ent.RemoteHandle);
            var handleTarget = NetToEntity(entTarget.RemoteHandle);

            LogManager.DebugLog("AE2E_3");
            if (handleSource == null || handleTarget == null)
            {
                return;
            }
            LogManager.DebugLog("AE2E_4");
            int bone = 0;

            if (!string.IsNullOrWhiteSpace(info.Bone))
            {
                if (entTarget is RemotePlayer || entTarget is RemotePed)
                {
                    bone = Function.Call <int>(Hash.GET_PED_BONE_INDEX, handleTarget.Handle, (int)Enum.Parse(typeof(Bone), info.Bone, true));
                }
                else
                {
                    bone = new Prop(handleTarget.Handle).Bones[info.Bone];
                }
            }

            if (bone == -1)
            {
                bone = 0;
            }

            LogManager.DebugLog("ATTACHING " + handleSource.Handle + " TO " + handleTarget.Handle +
                                " WITH BONE " + bone);

            Function.Call(Hash.ATTACH_ENTITY_TO_ENTITY, handleSource.Handle, handleTarget.Handle,
                          bone,
                          info.PositionOffset.X, info.PositionOffset.Y, info.PositionOffset.Z,
                          info.RotationOffset.X, info.RotationOffset.Y, info.RotationOffset.Z,
                          false, // p9
                          false, // useSoftPinning
                          false, // collision
                          false, // p12
                          2,     // vertexIndex
                          true   // fixedRot
                          );
        }
Esempio n. 55
0
 //---------------------------------------------------------------------
 public override void defAllProp(Dictionary <string, string> map_param)
 {
     mPropWeaponItemId = defProp <int>(map_param, "WeaponItemId", 0);
 }
Esempio n. 56
0
        public Prop <Dictionary <string, List <ChatMsgRecord> > > mPropMapMsgRecord;// 好友聊天记录列表

        //-------------------------------------------------------------------------
        public override void defAllProp(Dictionary <string, string> map_param)
        {
            mPropMapFriend    = defProp <Dictionary <string, PlayerInfo> >(map_param, "MapFriend", new Dictionary <string, PlayerInfo>());
            mPropMapMsgRecord = defProp <Dictionary <string, List <ChatMsgRecord> > >(map_param, "MapMsgRecord", new Dictionary <string, List <ChatMsgRecord> >());
        }
        /// <summary>
        ///     Draw a specified entity
        /// </summary>
        /// <param name="e">The entity to draw</param>
        private void DrawEntity(Entity e)
        {
            if (!e.IsOnScreen || e.IsOccluded) return;

            var textScale = .25f;

            //Set text color
            var c = Color.FromArgb(150, Color.White);
            if (_selectedEntity != null && e.Equals(_selectedEntity)) c = Color.Red;
            else {
                switch (GTAFuncs.GetEntityType(e)) {
                    case GTAFuncs.EntityType.Ped:
                        c = new Ped(e.Handle).IsPlayer
                            ? Color.FromArgb(150, Color.CornflowerBlue)
                            : Color.FromArgb(150, Color.Yellow);
                        break;
                    case GTAFuncs.EntityType.Vehicle:
                        c = Color.FromArgb(150, Color.DeepPink);
                        break;
                    case GTAFuncs.EntityType.Prop:
                        c = Color.FromArgb(150, Color.Green);
                        break;
                }
            }

            //Create entity info lines
            var lines = new List<string>();

            switch(GTAFuncs.GetEntityType(e)) {
                case GTAFuncs.EntityType.Ped:
                    Ped ped = new Ped(e.Handle);
                    if (ped.IsPlayer) {
                        Player pl = GTAFuncs.GetPedPlayer(ped);
                        lines.Add(pl.Name);
                        lines.Add("Player #" + pl.Handle);
                        if (GTAFuncs.GetPlayerInvincible(pl)) lines.Add("INVINCIBLE");
                    }
                    lines.Add("Ped #" + ped.Handle);
                    e = ped;
                    break;
                case GTAFuncs.EntityType.Vehicle:
                    Vehicle v = new Vehicle(e.Handle);
                    lines.Add("Vehicle #" + v.Handle);
                    lines.Add(v.FriendlyName);
                    lines.Add(v.DisplayName);
                    e = v;
                    break;
                case GTAFuncs.EntityType.Prop:
                    Prop prop = new Prop(e.Handle);
                    lines.Add("Prop #" + prop.Handle);
                    lines.Add("Model: " + prop.Model.Hash);
                    e = prop;
                    break;
                default:
                    lines.Add("Entity #" + e.Handle);
                    break;
            }

            Entities.Add(e.Handle, e);

            //Draw entity info
            var screenPos = GTAFuncs.WorldToScreen(e.Position);
            var contain =
                new Rectangle(
                    new Point((int) screenPos.X,
                        (int)screenPos.Y + (GTAFuncs.GetEntityType(e) == GTAFuncs.EntityType.Ped && new Ped(e.Handle).IsInVehicle() ? lines.Count * -10 : 0)),
                    new Size(50, (lines.Count*11) - 1));

            for (var i = 0; i < lines.Count; i++) {
                GTAFuncs.SetTextDropShadow(2, Color.FromArgb(255, 0, 0, 0));
                new UIText(lines[i], new Point(0, (i*10)), textScale, Color.FromArgb(255, c), 0, true).Draw(
                    new Size(contain.Location));
                GTAFuncs.SetTextDropShadow(0, Color.Transparent);
            }

            EntityClickBoxes.Add(e, contain);
            DrawEntBox(e, c);
        }
 private void Awake()
 {
     prop = GetComponent <Prop>();
     prop.EActionEventReceived += onActionEventReceived;
 }
Esempio n. 59
0
		public MoonGate(string name, string keyword, int keywordId, Prop prop)
		{
			this.Name = name;
			this.Keyword = keyword;
			this.KeywordId = keywordId;
			this.Prop = prop;
		}
Esempio n. 60
0
        static void Main(string[] args)
        {
            //A simple example

            Prop.ForAll <double[]>(xs => xs.Reverse().Reverse().SequenceEqual(xs, new Eq()))
            .QuickCheck("RevRev");

            Prop.ForAll <int[]>(xs => xs.Reverse().SequenceEqual(xs))
            .QuickCheck("RevId");

            //Grouping properties : not yet implemented


            //--------Properties--------------
            Prop.ForAll <double[]>(xs => xs.Reverse().Reverse().SequenceEqual(xs))
            .QuickCheck("RevRevFloat");

            //conditional properties
            Prop.ForAll <int, int[]>((x, xs) => xs.Insert(x).IsOrdered().When(xs.IsOrdered()))
            .QuickCheck("Insert");

            Prop.ForAll <int>(a => new Func <bool>(() => 1 / a == 1 / a).When(a != 0))
            .QuickCheck("DivByZero");

            //counting trivial cases
            Prop.ForAll <int, int[]>((x, xs) =>
                                     xs.Insert(x).IsOrdered()
                                     .When(xs.IsOrdered())
                                     .Classify(xs.Count() == 0, "trivial"))
            .QuickCheck("InsertTrivial");

            //classifying test values
            Prop.ForAll <int, int[]>((x, xs) =>
                                     xs.Insert(x).IsOrdered()
                                     .When(xs.IsOrdered())
                                     .Classify(new [] { x }.Concat(xs).IsOrdered(), "at-head")
                                     .Classify(xs.Concat(new int[] { x }).IsOrdered(), "at-tail"))
            .QuickCheck("InsertClassify");

            //collecting data values
            Prop.ForAll <int, int[]>((x, xs) =>
                                     xs.Insert(x).IsOrdered()
                                     .When(xs.IsOrdered())
                                     .Collect("length " + xs.Count().ToString()))
            .QuickCheck("InsertCollect");

            //combining observations
            Prop.ForAll <int, int[]>((x, xs) =>
                                     xs.Insert(x).IsOrdered()
                                     .When(xs.IsOrdered())
                                     .Classify(new [] { x }.Concat(xs).IsOrdered(), "at-head")
                                     .Classify(xs.Concat(new [] { x }).IsOrdered(), "at-tail")
                                     .Collect("length " + xs.Count().ToString()))
            .QuickCheck("InsertCombined");

            //---labelling sub properties-----
            Prop.ForAll <int, int>((n, m) => {
                var res = n * m;
                return((new Func <bool>(() => res / m == n)).When(m != 0.0).Label("div1")
                       .And((new Func <bool>(() => res / n == m)).When(n != 0.0).Label("div2"))
                       .And((res > m).Label("lt1"))
                       .And((res > n).Label("lt2"))
                       .Label(string.Format("evidence = {0}", res)));
            }).QuickCheck("Multiple labels");


            Prop.ForAll <int, int>((m, n) => {
                var result = m + n;
                return((result >= m).Label("result > #1")
                       .And(result >= n).Label("result > #2")
                       .And(result < m + n).Label("result not sum"));
            }).QuickCheck("ComplexProp");

            Prop.ForAll <int>(x => false.Label("Always false")
                              .And(Math.Abs(x) - x == 0))
            .QuickCheck("Label");


            //-------Test data generators-----------
            //can't be made generic, only in separate method?
            Func <int[], Gen <int> > chooseFromList = xs =>
                                                      from i in Gen.Choose(0, xs.Length - 1)
                                                      select xs[i];

            var chooseBool = Gen.OneOf(Gen.Constant(true), Gen.Constant(false));

            var chooseBool2 = Gen.Frequency(
                new WeightAndValue <Gen <bool> >(2, Gen.Constant(true)),
                new WeightAndValue <Gen <bool> >(1, Gen.Constant(false)));

            //the size of test data : see matrix method

            //generating recursive data types: not so common in C#?

            // generating functions:
            Prop.ForAll((Func <int, int> f, Func <int, int> g, ICollection <int> a) => {
                var l1 = a.Select(x => f(g(x)));
                var l2 = a.Select(g).Select(f);
                return(l1.SequenceEqual(l2));
            }).QuickCheck();

            //generators support select, selectmany and where
            var gen = from x in Arb.Generate <int>()
                      from int y in Gen.Choose(5, 10)
                      where x > 5
                      select new { Fst = x, Snd = y };

            //registering default arbitrary instances
            Arb.Register <MyArbitraries>();

            Prop.ForAll <long>(l => l + 1 > l)
            .QuickCheck();

            Prop.ForAll <string>(s => true)
            .Check(new Configuration {
                Name = "Configuration Demo", MaxNbOfTest = 500
            });

            // discard

            Prop.ForAll <int>(s => s >= 4 || Prop.Discard <bool>()).QuickCheck();

            Console.WriteLine();

            // replay
            Prop.ForAll <string>(s => s == null)
            .Label("Replay")
            .Check(new Configuration {
                MaxNbOfTest = 1, Replay = Random.StdGen.NewStdGen(1, 1)
            });

            Console.WriteLine();

            Prop.ForAll((IEnumerable <int> a, IEnumerable <int> b) =>
                        a.Except(b).Count() <= a.Count())
            .QuickCheck();

            Console.ReadKey();
        }