コード例 #1
0
        public bool BuyUpgrade(string key)
        {
            key = key.ToLower();
            if (string.IsNullOrEmpty(key))
            {
                return(false);
            }
            key = key.ToLower();
            if (!PossibleUpgrades.ContainsKey(key))
            {
                return(false);
            }
            var upgrade = PossibleUpgrades[key];

            if (!GamePlayScreen.MoneyManager.CanBuy(upgrade.Price))
            {
                return(false);
            }
            if (SetProperties.ContainsKey(upgrade.Type.ToLower()))
            {
                SetProperties[upgrade.Type.ToLower()](upgrade.Value);
                GamePlayScreen.MoneyManager.Buy(upgrade.Price);
                BoughtUpgrades.Add(key);
                Price += upgrade.Price;
            }
            else
            {
                //LogFramework.AddLog(string.Format("Tower {0} kennt Property {1} nicht!", TowerName, upgrade.Type.ToLower()), false, LogType.Error);
                return(false);
            }
            ReadPossibleUpgrades();
            GamePlayScreen.GuiManager.UpdateTowerWindow();
            GamePlayScreen.TowerManager.UpdateRangeMarkerSize();
            return(true);
        }
コード例 #2
0
 public JsonObject(SetProperties callback)
 {
     if (callback != null)
     {
         callback(this);
     }
 }
コード例 #3
0
        /// <summary>
        /// Handles operation SetProperties: Sets the Item.Properties of an Item and ultimately sends event ItemPropertiesSet to other clients.
        /// </summary>
        public OperationResponse OperationSetProperties(PeerBase peer, OperationRequest request, SendParameters sendParameters)
        {
            var operation = new SetProperties(peer.Protocol, request);

            if (!operation.IsValid)
            {
                return(new OperationResponse(request.OperationCode)
                {
                    ReturnCode = (int)ReturnCode.InvalidOperationParameter, DebugMessage = operation.GetErrorMessage()
                });
            }

            operation.OnStart();
            Item item;

            if (string.IsNullOrEmpty(operation.ItemId))
            {
                item = this.Avatar;

                // set return values
                operation.ItemId = item.Id;
            }
            else if (this.TryGetItem(operation.ItemId, out item) == false)
            {
                return(operation.GetOperationResponse((int)ReturnCode.ItemNotFound, "ItemNotFound"));
            }

            return(this.ItemOperationSetProperties(item, operation, sendParameters));
        }
コード例 #4
0
        /// <summary>
        /// Finish the packet.
        /// (Checksum and inline length byte.)
        /// Also checks if all properties have been set.
        /// </summary>
        /// <exception cref="InvalidOperationException">
        /// Not all required properties have been set.</exception>
        public void Finish()
        {
            // if all set or nothing has changed then there is nothing to do
            if (propsSet == SetProperties.AllOk)
            {
                return;
            }

            if (propsSet != SetProperties.AllButChecksum)
            {
                SetProperties missing = (SetProperties)(SetProperties.AllButChecksum - this.propsSet);
                throw new InvalidOperationException("Properties not set: " + missing.ToString());
            }

            // Assumes full packet size incl. checksum!
            // optimize using local copy
            int count = this.count;

            // set data size byte (4th byte), = total packet size - 5
            // counting bytes from command (5th) byte till end, excluding last byte = checksum
            buffer[(int)Ssm2PacketIndex.DataSize] =
                (byte)(count - ((int)Ssm2PacketIndex.DataSize + 2));

            // reserve last byte for checksum, checksum method assumes Count of full packet
            buffer[count - 1] = ChecksumCalculated;
            this.propsSet     = SetProperties.AllOk;
        }
コード例 #5
0
ファイル: FreezeTower.cs プロジェクト: hakanaku2009/svn-dump
 protected override void GenerateAccessToCustomProperties()
 {
     SetProperties.Add("freezepercentage", SetFreezePercentage);
     SetProperties.Add("freezetime", SetFreezeTime);
     GetProperties.Add("freezepercentage", GetFreezePercentage);
     GetProperties.Add("freezetime", GetFreezeTime);
 }
コード例 #6
0
        private OperationResponse ItemOperationSetProperties(Item item, SetProperties operation, SendParameters sendParameters)
        {
            MethodReturnValue result = this.CheckAccess(item);

            if (result.IsOk)
            {
                item.SetProperties(operation.PropertiesSet, operation.PropertiesUnset);
                var eventInstance = new ItemPropertiesSet
                {
                    ItemId             = item.Id,
                    PropertiesRevision = item.PropertiesRevision,
                    PropertiesSet      = operation.PropertiesSet,
                    PropertiesUnset    = operation.PropertiesUnset
                };

                var eventData = new EventData((byte)EventCode.ItemPropertiesSet, eventInstance);
                sendParameters.ChannelId = Settings.ItemEventChannel;
                var message = new ItemEventMessage(item, eventData, sendParameters);
                item.EventChannel.Publish(message);

                // no response sent
                operation.OnComplete();
                return(null);
            }

            return(operation.GetOperationResponse(result));
        }
コード例 #7
0
        public override OperationResponse Handle(MmoActor actor, OperationRequest request, SendParameters sendParameters)
        {
            var operation = new SetProperties(actor.Peer.Protocol, request);

            if (!operation.IsValid)
            {
                return(new OperationResponse(request.OperationCode)
                {
                    ReturnCode = (int)ReturnCode.InvalidOperationParameter, DebugMessage = operation.GetErrorMessage()
                });
            }

            operation.OnStart();
            Item item;

            if (false == operation.ItemType.HasValue || string.IsNullOrEmpty(operation.ItemId))
            {
                item = actor.Avatar;

                // set return values
                operation.ItemId   = item.Id;
                operation.ItemType = item.Type;
            }
            else if (actor.TryGetItem(operation.ItemType.Value, operation.ItemId, out item) == false)
            {
                return(operation.GetOperationResponse((int)ReturnCode.ItemNotFound, "ItemNotFound"));
            }

            return(this.ItemOperationSetProperties(item, operation, sendParameters, actor));
        }
コード例 #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="JsonConverter"/> class.
 /// </summary>
 /// <param name="callback">The callback.</param>
 public JsonConverter(SetProperties callback)
 {
     if (callback != null)
     {
         callback(this);
     }
 }
コード例 #9
0
 protected override void GenerateAccessToCustomProperties()
 {
     SetProperties.Add("moneytime", SetMoneyTime);
     SetProperties.Add("moneyamount", SetMoneyAmount);
     GetProperties.Add("moneytime", GetMoneyTime);
     GetProperties.Add("moneyamount", GetMoneyAmount);
     GetProperties.Add("moneypersecond", GetMoneyPerSecond);
 }
コード例 #10
0
        private void GenerateAccessToProperties()
        {
            SetProperties.Add("damage", ChangeDamage);
            SetProperties.Add("range", ChangeRange);
            SetProperties.Add("speed", ChangeSpeed);
            SetProperties.Add("interval", ChangeInterval);

            GenerateAccessToCustomProperties();
        }
コード例 #11
0
ファイル: HealthTower.cs プロジェクト: hakanaku2009/svn-dump
        protected override void GenerateAccessToCustomProperties()
        {
            SetProperties.Add("healthtime", SetHealthTime);
            SetProperties.Add("healthamount", SetHealthAmount);

            GetProperties.Add("healthtime", GetHealthTime);
            GetProperties.Add("healthamount", GetHealthAmount);
            GetProperties.Add("healthpersecond", GetHealthPerSecond);
        }
コード例 #12
0
ファイル: PoisonTower.cs プロジェクト: hakanaku2009/svn-dump
        protected override void GenerateAccessToCustomProperties()
        {
            SetProperties.Add("poisontime", SetPoisonTime);
            SetProperties.Add("poisonamount", SetPoisonAmount);
            SetProperties.Add("poisoncountertime", SetDotCounterTime);

            GetProperties.Add("poisontime", GetPoisonTime);
            GetProperties.Add("poisonamount", GetPoisonAmount);
            GetProperties.Add("poisoncountertime", GetDotCounterTime);
            GetProperties.Add("damageoverall", GetDamageOverall);
        }
コード例 #13
0
        private bool ExecuteCore()
        {
            var properties = new Dictionary <string, string>();

            foreach (var prop in SetProperties.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
            {
                var key   = prop.Substring(0, prop.IndexOf('=')).Trim();
                var value = prop.Substring(prop.IndexOf('=') + 1).Trim();
                if (!string.IsNullOrEmpty(key))
                {
                    properties[key] = value;
                }
            }
            var projectFiles = CandidateReferenceProjects
                               .Select(p => p.GetMetadata("FullPath"))
                               .ToArray();
            var propertyArray = new IDictionary[projectFiles.Length];

            for (int i = 0; i < projectFiles.Length; i++)
            {
                propertyArray[i] = properties;
            }
            var removePropertiesArray = Enumerable.Repeat((IList <string>)UndefineProperties.Split(new[] { ';' }).Select(p => p.Trim()).Where(s => !string.IsNullOrEmpty(s)).ToArray(), propertyArray.Length).ToArray();
            BuildEngineResult result  = BuildEngine3.BuildProjectFilesInParallel(
                projectFiles,
                Enumerable.Repeat("GetTargetPath", projectFiles.Length).ToArray(),
                propertyArray,
                removePropertiesArray,
                new string[projectFiles.Length],
                true
                );

            if (!result.Result)
            {
                Log.LogError("Building 'GetTargetPath' Failed.");
                return(false);
            }
            var assemblyNameToProject = new Dictionary <string, LiveReferenceData>();

            for (int i = 0; i < projectFiles.Length; i++)
            {
                string projectFile = projectFiles[i];
                IDictionary <string, ITaskItem[]> targetOutputs = result.TargetOutputsPerProject[i];
                ITaskItem targetPath   = targetOutputs["GetTargetPath"].First();
                string    assemblyName = targetPath.GetMetadata("FileName");
                assemblyNameToProject[assemblyName] = new LiveReferenceData
                {
                    Project    = projectFile,
                    TargetPath = targetPath.GetMetadata("FullPath")
                };
            }
            File.WriteAllText(LiveReferenceCacheFile, JsonConvert.SerializeObject(assemblyNameToProject, Formatting.Indented));
            return(true);
        }
コード例 #14
0
 /// <summary>
 /// Parses packet by taking packet bytes, does not use a copy!
 /// Assumes complete packet, does not validate.
 /// May want to call Check () afterwards.
 /// (Packet size is being calculated based on packet length byte.)
 /// </summary>
 /// <param name="buffer">
 /// A <see cref="System.Byte[]"/>. Length can be larger than needed.
 /// </param>
 /// <exception cref='ArgumentNullException'>
 /// </exception>
 /// <exception cref='ArgumentOutOfRangeException'>
 /// Length ≥ 6 required.
 /// </exception>
 public virtual void FromBytes(byte[] buffer)
 {
     TakeBuffer(buffer, PacketSizeMin);
     // Calculate packet size based on DataSize byte so given byte[] can be larger than needed.
     // total count = DataSize + remaining header bytes + checksum byte
     this.count = this.PayloadSize + ((int)Ssm2PacketIndex.DataSize + 1 + 1);
     if (buffer.Length < this.count)
     {
         throw new ArgumentOutOfRangeException("buffer.Length < expected");
     }
     // Assume packet to be complete incl. checksum.
     this.propsSet = SetProperties.AllOk;
 }
コード例 #15
0
        /// <summary>
        /// Set flag to indicate that this part of the packet has been set.
        /// Also unsets checksum flag as it needs recalculation in method Finish().
        /// </summary>
        /// <param name='toSet'>
        /// The flag to set.
        /// </param>
        protected void UpdateFlags(SetProperties toSet)
        {
            SetProperties props = this.propsSet;

            // set flag
            props |= toSet;

            // unset checksum flag
            // "~": bitwise complement operation on its operand,
            //      which has the effect of reversing each bit
            props &= ~SetProperties.Checksum;

            this.propsSet = props;
        }
コード例 #16
0
 public void LoadFromFlatLayout(FlatLayout savedLayout, PuzzleLayout gameLayout)
 {
     savedLayout.Connections.ForEach(gameLayout.AddNodeConnections);
     savedLayout.Objects.ForEach(puzzleObject =>
     {
         var properties = new SetProperties();
         puzzleObject.Properties.ForEach(property =>
         {
             var type      = Type.GetType(property.Type);
             var converter = System.ComponentModel.TypeDescriptor.GetConverter(type);
             var value     = converter.ConvertFromInvariantString(property.Value);
             properties.Add(property.Key, value);
         });
         gameLayout.PlaceObject(puzzleObject.Type, puzzleObject.Position, properties);
     });
 }
コード例 #17
0
ファイル: Ssm2Packet.cs プロジェクト: src0x/LibSSM2
        /// <summary>
        /// Finish the packet.
        /// (Checksum and inline length byte.)
        /// Also checks if all properties have been set.
        /// </summary>
        /// <exception cref="InvalidOperationException">
        /// Not all required properties have been set.</exception>
        public void Finish()
        {
            // if all set or nothing has changed then there is nothing to do
            if (propsSet == SetProperties.AllOk)
                return;

            if (propsSet != SetProperties.AllButChecksum) {
                SetProperties missing = (SetProperties)(SetProperties.AllButChecksum - this.propsSet);
                throw new InvalidOperationException ("Properties not set: " + missing.ToString ());
            }

            // Assumes full packet size incl. checksum!
            // optimize using local copy
            int count = this.count;

            // set data size byte (4th byte), = total packet size - 5
            // counting bytes from command (5th) byte till end, excluding last byte = checksum
            buffer[(int)Ssm2PacketIndex.DataSize] =
                (byte)(count - ((int)Ssm2PacketIndex.DataSize + 2));

            // reserve last byte for checksum, checksum method assumes Count of full packet
            buffer[count - 1] = ChecksumCalculated;
            this.propsSet = SetProperties.AllOk;
        }
コード例 #18
0
 protected override void GenerateAccessToCustomProperties()
 {
     SetProperties.Add("percentage", SetPercentage);
     GetProperties.Add("percentage", GetPercentage);
 }
コード例 #19
0
 public T ObjectAt(string type, TilePos position, SetProperties properties = null)
 {
     Sut.PlaceObject(type, position, properties);
     return(This);
 }
コード例 #20
0
ファイル: Ssm2Packet.cs プロジェクト: src0x/LibSSM2
 /// <summary>
 /// Parses packet by taking packet bytes, does not use a copy!
 /// Assumes complete packet, does not validate.
 /// May want to call Check () afterwards.
 /// (Packet size is being calculated based on packet length byte.)
 /// </summary>
 /// <param name="buffer">
 /// A <see cref="System.Byte[]"/>. Length can be larger than needed.
 /// </param>
 /// <exception cref='ArgumentNullException'>
 /// </exception>
 /// <exception cref='ArgumentOutOfRangeException'>
 /// Length ≥ 6 required.
 /// </exception>
 public virtual void FromBytes(byte[] buffer)
 {
     TakeBuffer (buffer, PacketSizeMin);
     // Calculate packet size based on DataSize byte so given byte[] can be larger than needed.
     // total count = DataSize + remaining header bytes + checksum byte
     this.count = this.PayloadSize + ((int)Ssm2PacketIndex.DataSize + 1 + 1);
     if (buffer.Length < this.count)
         throw new ArgumentOutOfRangeException ("buffer.Length < expected");
     // Assume packet to be complete incl. checksum.
     this.propsSet = SetProperties.AllOk;
 }
コード例 #21
0
 protected override void GenerateAccessToCustomProperties()
 {
     SetProperties.Add("shotcostmultiplier", SetShotCostMultiplier);
     GetProperties.Add("shotcostmultiplier", GetShotCostMultiplier);
     GetProperties.Add("costpershot", GetCostPerShot);
 }
コード例 #22
0
ファイル: Ssm2Packet.cs プロジェクト: src0x/LibSSM2
        /// <summary>
        /// Set flag to indicate that this part of the packet has been set.
        /// Also unsets checksum flag as it needs recalculation in method Finish().
        /// </summary>
        /// <param name='toSet'>
        /// The flag to set.
        /// </param>
        protected void UpdateFlags(SetProperties toSet)
        {
            SetProperties props = this.propsSet;
            // set flag
            props |= toSet;

            // unset checksum flag
            // "~": bitwise complement operation on its operand,
            //      which has the effect of reversing each bit
            props &= ~SetProperties.Checksum;

            this.propsSet = props;
        }
コード例 #23
0
ファイル: MmoActor.cs プロジェクト: azanium/PopBloop-Unity
        /// <summary>
        ///   The set properties.
        /// </summary>
        /// <param name = "item">
        ///   The mmo item.
        /// </param>
        /// <param name = "operation">
        ///   The operation.
        /// </param>
        /// <param name = "sendParameters">
        ///   The send Parameters.
        /// </param>
        /// <returns>
        ///   error code ok
        /// </returns>
        private OperationResponse ItemOperationSetProperties(Item item, SetProperties operation, SendParameters sendParameters)
        {
            MethodReturnValue result = this.CheckAccess(item);
            if (result)
            {
                item.SetProperties(operation.PropertiesSet, operation.PropertiesUnset);
                var eventInstance = new ItemPropertiesSet
                    {
                        ItemId = item.Id,
                        ItemType = item.Type,
                        PropertiesRevision = item.PropertiesRevision,
                        PropertiesSet = operation.PropertiesSet,
                        PropertiesUnset = operation.PropertiesUnset
                    };

                var eventData = new EventData((byte)EventCode.ItemPropertiesSet, eventInstance);
                sendParameters.ChannelId = Settings.ItemEventChannel;
                var message = new ItemEventMessage(item, eventData, sendParameters);
                item.EventChannel.Publish(message);

                // no response sent
                operation.OnComplete();
                return null;
            }

            return operation.GetOperationResponse(result);
        }
コード例 #24
0
ファイル: MmoActor.cs プロジェクト: azanium/PopBloop-Unity
        /// <summary>
        ///   Handles operation <see cref = "SetProperties" />: Sets the <see cref = "Item.Properties" /> of an <see cref = "Item" /> and ultimately sends event <see cref = "ItemPropertiesSet" /> to other clients.
        /// </summary>
        /// <param name = "peer">
        ///   The client peer.
        /// </param>
        /// <param name = "request">
        ///   The request.
        /// </param>
        /// <param name = "sendParameters">
        ///   The send Parameters.
        /// </param>
        /// <returns>
        ///   Null or an <see cref = "OperationResponse" /> with error code <see cref = "ReturnCode.ItemNotFound" />.
        /// </returns>
        public OperationResponse OperationSetProperties(PeerBase peer, OperationRequest request, SendParameters sendParameters)
        {
            var operation = new SetProperties(peer.Protocol, request);
            if (!operation.IsValid)
            {
                return new OperationResponse(request.OperationCode) { ReturnCode = (int)ReturnCode.InvalidOperationParameter, DebugMessage = operation.GetErrorMessage() };
            }

            operation.OnStart();
            Item item;
            if (false == operation.ItemType.HasValue || string.IsNullOrEmpty(operation.ItemId))
            {
                item = this.Avatar;

                // set return values
                operation.ItemId = item.Id;
                operation.ItemType = item.Type;
            }
            else if (this.TryGetItem(operation.ItemType.Value, operation.ItemId, out item) == false)
            {
                return operation.GetOperationResponse((int)ReturnCode.ItemNotFound, "ItemNotFound");
            }

            return this.ItemOperationSetProperties(item, operation, sendParameters);
        }