コード例 #1
0
        public void MoveTest()
        {
            Player   John          = new Player("John", "Random Player");
            Location TestLocation1 = new Location("Hallway", "This is a long well lit hallway");
            Location TestLocation2 = new Location("Small Closet", "A small dark closet, with an odd smell");
            Location TestLocation3 = new Location("Small Garden", "There are many small shrubs and flowers growing from well tended garden beds.");

            Path TestPath  = new Path();
            Path TestPath2 = new Path();
            Path TestPath3 = new Path();


            TestLocation1.Path = TestPath;
            TestPath.SetLocation("w", TestLocation2);
            TestPath.SetLocation("n", TestLocation3);

            TestLocation2.Path = TestPath2;
            TestPath2.SetLocation("e", TestLocation1);
            TestPath2.SetLocation("ne", TestLocation3);

            TestLocation3.Path = TestPath3;
            TestPath3.SetLocation("s", TestLocation1);
            TestPath3.SetLocation("sw", TestLocation2);

            John.Location = TestLocation1;


            MoveCommand      TestMove      = new MoveCommand();
            CommandProcessor TestProcessor = new CommandProcessor();

            TestProcessor.AddCommand(TestMove);

            Assert.AreEqual(TestLocation2.FullDescription, TestProcessor.Execute(John, new string[] { "move", "west" }));
            Assert.AreEqual(TestLocation3.FullDescription, TestProcessor.Execute(John, new string[] { "move", "north_east" }));
        }
コード例 #2
0
        public override bool ExecuteLogic()
        {
            var hpMinus = _hPChangeFactory.Create(new StatChangeData {
                value = (Fix64)damage.value, receiver = Target.UnitModel, sender = _sender
            });

            _command.AddCommand(hpMinus);

            return(true);
        }
コード例 #3
0
        public void Apply(ServerRuleApplyTimeEnum applyTime, CommandProcessor theProcessor)
        {
            try
            {
                if (_studyRulesEngine == null || !_studyRulesEngine.RuleApplyTime.Equals(applyTime))
                {
                    _studyRulesEngine = new ServerRulesEngine(applyTime, _location.ServerPartitionKey);
                    _studyRulesEngine.Load();
                }

                List <string> files = GetFirstInstanceInEachStudySeries();
                if (files.Count == 0)
                {
                    string message =
                        String.Format("Unexpectedly unable to find SOP instances for rules engine in each series in study: {0}",
                                      _location.StudyInstanceUid);
                    Platform.Log(LogLevel.Error, message);
                    throw new ApplicationException(message);
                }

                Platform.Log(LogLevel.Info, "Processing Study Level rules for study {0} on partition {1} at {2} apply time",
                             _location.StudyInstanceUid, _partition.Description, applyTime.Description);

                foreach (string seriesFilePath in files)
                {
                    var theFile = new DicomFile(seriesFilePath);
                    theFile.Load(DicomReadOptions.Default);
                    var context =
                        new ServerActionContext(theFile, _location.FilesystemKey, _partition, _location.Key, theProcessor)
                    {
                        RuleEngine = _studyRulesEngine
                    };
                    _studyRulesEngine.Execute(context);

                    ProcessSeriesRules(theFile, theProcessor);
                }

                if (applyTime.Equals(ServerRuleApplyTimeEnum.StudyProcessed))
                {
                    // This is a bit kludgy, but we had a problem with studies with only 1 image incorectlly
                    // having archive requests inserted when they were scheduled for deletion.  Calling
                    // this command here so that if a delete is inserted at the study level, we will remove
                    // the previously inserted archive request for the study.  Note also this has to be done
                    // after the rules engine is executed.
                    theProcessor.AddCommand(new InsertArchiveQueueCommand(_location.ServerPartitionKey, _location.Key));
                }
            }
            finally
            {
                if (_studyRulesEngine != null)
                {
                    _studyRulesEngine.Complete(_studyRulesEngine.RulesApplied);
                }
            }
        }
コード例 #4
0
        public ProjectileManager(WorldModel worldModel, CommandProcessor commandProcessor,
                                 ProjectileRepository projectileRepository,
                                 IFactory <ProjectileModel, RemoveProjectileCommand> removeProjectileFactory)
        {
            _worldModel              = worldModel;
            _projectileRepository    = projectileRepository;
            _commandProcessor        = commandProcessor;
            _removeProjectileFactory = removeProjectileFactory;

            _commandProcessor.AddCommand(this);
        }
コード例 #5
0
        public void LookTest()
        {
            Player John = new Player("John", "Random Player");

            LookCommand TestLook = new LookCommand();

            CommandProcessor TestProcessor = new CommandProcessor();

            TestProcessor.AddCommand(TestLook);

            Console.WriteLine(TestProcessor.Execute(John, new string[] { "look", "at", "me" }));

            Assert.AreEqual(John.FullDescription, TestProcessor.Execute(John, new string[] { "look", "at", "me" }));
        }
コード例 #6
0
        public override void Execute()
        {
            var targets            = _world.GetAllyUnitsTo(_unit.Alliance);
            List <UnitModel> targs = targets.GetAllDistUnit1(_unit, _data.AbilityRange);

            foreach (UnitModel targ in targs)
            {
                var giveShield = _statChangeFactory.Create(StatChanges.AddedShield, new StatChangeData {
                    value = (Fix64)_data.ShieldValue, receiver = targ, sender = _unit
                });
                _command.AddCommand(giveShield);
                //this is when I have to start putting more logic in the commands, because it ain't goin here.
            }
        }
コード例 #7
0
 public override void Execute()
 {
     if (Target.notNull())
     {
         if (_unit.Position.IsInRange(Target.GetPosition(), _data.AbilityRange))
         {
             var dmg = _HPChangeFactory.Create(new StatChangeData {
                 value    = (Fix64)_data.DamageValue,
                 receiver = Target.UnitModel,
                 sender   = _unit
             });
             _command.AddCommand(dmg);
         }
     }
 }
コード例 #8
0
        public UnitModel SpawnUnit(UnitData unitData, AllianceType alliance, WorldPosition position
                                   //IFactory<UnitModel, Ability2> ability2Factory,
                                   //IFactory<UnitModel, Ability3> ability3Factory,
                                   //IFactory<UnitModel, Ability4> ability4Factory,
                                   //IFactory<UnitModel, Ability5> ability5Factory

                                   )
        {
            var unit = _unitFactory.Create(unitData, alliance);

            unit.SetPosition(position);

            foreach (var unitAbility in unitData.abilityIDs)
            {
                var ability = _abilityRepository.CreateAbilityFromId(unitAbility.AbilityId, unit, unitAbility.AbilityOverride ? unitAbility.AbilityOverrideData : null);
                unit.Abilities.Add(ability);
                _commandProcessor.AddCommand(ability);
            }

            /* I tried and couldn't get this to work
             * ITargetAbility abil1 = ability2Factory.Create (unit);   //this is not at all how it will really work
             * _commandProcessor.AddCommand (abil1);
             * unit.abilities [1] = abil1;
             *
             * ITargetAbility abil2 = ability5Factory.Create (unit);
             * _commandProcessor.AddCommand (abil2);
             * unit.abilities [2] = abil2;
             *
             * ITargetAbility abil3 = ability4Factory.Create (unit);
             * _commandProcessor.AddCommand (abil3);
             * unit.abilities [3] = abil3;
             *
             * ITargetAbility abil4 = ability3Factory.Create (unit);
             * _commandProcessor.AddCommand (abil4);
             * unit.abilities [4] = abil4;
             *
             */
            _worldModel.Units.Add(unit);
            //load up abilities; add them to unit: stored inside configuration of unit as array of string IDs.
            //helper class: takes ability registry: unit manager and spawn unit command: create ability by ID: pass the string,
            //and it returns the real IAbility state. That class will take the configuration ability data, define
            //what kind of class we will create for this particular ability.

            return(unit);
        }
コード例 #9
0
        public void ShieldReduce()
        {
            //			Debug.Log ("shield = " + _unit.shield.getAddedValue());
            //			Debug.Log ("finalShieldReduceTick = " + _finalShieldReduceTick);

            if (_finalShieldReduceTick == -1 && !shieldReducing && _unit.shield.value > Fix64.Zero)
            {
                _finalShieldReduceTick = _tick.currentTick + 10;                   //sets the tick counter
            }

            if (_finalShieldReduceTick != -1 && _tick.currentTick > _finalShieldReduceTick)
            {
                var shieldReduce = _statChangeFactory.Create(StatChanges.AddedShield, new StatChangeData {
                    value = (Fix64)(-5), receiver = _unit
                });
                _command.AddCommand(shieldReduce);

                _finalShieldReduceTick = -1;
            }
        }
コード例 #10
0
        public UnitModel SpawnUnit(UnitData unitData, AllianceType alliance, WorldPosition position)
        {
            var unit = _unitFactory.Create(unitData, alliance);

            unit.SetPosition(position);

            foreach (var unitAbility in unitData.abilityIDs)
            {
                var ability = _abilityRepository.CreateAbilityFromId(unitAbility.AbilityId, unit, unitAbility.AbilityOverride ? unitAbility.AbilityOverrideData : null);
                unit.Abilities.Add(ability);
                _commandProcessor.AddCommand(ability);
            }


            _worldModel.Units.Add(unit);
            //load up abilities; add them to unit: stored inside configuration of unit as array of string IDs.
            //helper class: takes ability registry: unit manager and spawn unit command: create ability by ID: pass the string,
            //and it returns the real IAbility state. That class will take the configuration ability data, define
            //what kind of class we will create for this particular ability.

            return(unit);
        }
コード例 #11
0
        public override bool ExecuteLogic()
        {
            Debug.Log("arrow execute  logic");
            var targets = _world.GetAllyUnitsTo(_sender.Alliance);              //this is enemy right now

            if (targets == null)
            {
                Debug.Log("(don't have allies) regular situation");
            }
            List <UnitModel> targs = targets.GetAllDistProjectile1(this, (Fix64)10);

            foreach (UnitModel targ in targs)
            {
                var hpPlus = _hPChangeFactory.Create(new StatChangeData {
                    value = damage.value, receiver = targ, sender = _sender
                });
                _command.AddCommand(hpPlus);
                Debug.Log("Im a target" + targ);
            }

            return(true);
        }
コード例 #12
0
 public void addThisToProcessor()
 {
     _commandProcessor.AddCommand(this);
 }
コード例 #13
0
 public void DespawnProjectile(IProjectile projectileModel)
 {
     _commandProcessor.AddCommand(_removeProjectileFactory.Create(projectileModel));
 }
コード例 #14
0
        protected override void DoTheLogic()
        {         //Debug.Log (_unit.hP.value);
            //Debug.Log (_unit.isAlive);
            //Debug.Log (_unit.isAlive + "unit alive or daed at health :" + _unit.hP.value);



            if (_unit.isAlive && _unit.hP.value <= 0 && !_unit.dying && !_unit.reviving)               //kills unit its hp goes below 0 // greater or equal to 0
            //Debug.Log (" die command ");
            {
                Debug.Log("going to die now");
                var die = _dieFactory.Create(_unit);
                _command.AddCommand(die);
            }
            if (!_unit.isAlive && _unit.hP.value > 0 && !_unit.reviving && !_unit.dying)               //&& unit not already reviving //greater than 0
            {
                var revive = _reviveFactory.Create(_unit);
                _command.AddCommand(revive);
            }

            ShieldReduce();              //ongoing shield losing
            KnockUpReduce();             //ongoing falling


            if (_unit.rooted > 0)
            {
                //	Debug.Log ("rooted");
            }
            if (_unit.silenced > 0)
            {
                //	Debug.Log ("silenced");
            }
            if (_unit.frozen > 0)
            {
                //	Debug.Log ("frozen");
            }
            if (_unit.knockedUp > 0)
            {
                //	Debug.Log ("knockedup");
            }
            if (_unit.hooked > 0)
            {
                //	Debug.Log ("hooked");
            }
            if (_unit.launched > 0)
            {
                //	Debug.Log ("launched");
            }
            if (_unit.petrified > 0)
            {
                //	Debug.Log ("petrified");
            }

            var target = _unit.GetAbilityTarget();


            if (_unit.isAlive && target != null)
            {
                var targPos = target.GetPosition();
                if (targPos.IsInRange(_unit.Position, _unit.moveRange.value))
                {
                    return;
                }
                var forwardVect = _unit.Position.GetFowardVect(targPos);
                _unit.SetPosition(_unit.Position + (forwardVect * _unit.moveSpeed.value * Time.fixedDeltaTime));
            }
        }
コード例 #15
0
ファイル: Synchronizer.cs プロジェクト: dokuflex/Dokuflex
        private void SynchronizeDeletedDirectories()
        {
            //Synchronize file sync table items of type folder vs on disk directories
            var folders = SyncTableManager.GetFolders();

            //Detect delete directories from disk
            foreach (var folder in folders)
            {
                if (!Directory.Exists(folder.Path))
                {
                    var command = new DeleteOnlineDirectoryCommand(_ticket, folder);
                    command.ExecuteError += new ExecuteErrorEventHandler(OnExecuteError);
                    _commandProcessor.AddCommand(command);
                }
            }
        }
コード例 #16
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to Swin-Adventure!");
            Console.WriteLine();

            Console.WriteLine("This is the first version of the game that is created by me. Enjoy the adventure in the game world!");
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("What is your name?");
            string name = Console.ReadLine();

            Console.WriteLine("How can you describe yourself(for example, a mighty programmer)?");
            string description = Console.ReadLine();

            Console.WriteLine("Let's begin your adventure today!");
            Player newPlayer   = new Player(name, description);
            bool   StayingOpen = true;

            // adding items and bag
            Item Itm1 = new Item(new string[] { "golden", "ring" }, "ring", "This is a golden ring for you");
            Item Itm2 = new Item(new string[] { "yellow", "small", "box" }, "box", "This is a small yellow box for you");
            Item Itm3 = new Item(new string[] { "purple", "ball" }, "ball", "That is a small and purple ball");
            Item Itm4 = new Item(new string[] { "green", "table" }, "table", "This is a dining table. Be careful with it!");
            Item Itm5 = new Item(new string[] { "orange" }, "orange", "This is an orange for you.");
            Bag  Bag1 = new Bag(new string[] { "red", "bag" }, "bag", "This is a large and red bag");

            // adding locations
            Location Loc1 = new Location("coffee house", " where you could go to coffee house each day");
            Location Loc2 = new Location("palace", "where the duke worked and lived");
            Location Loc3 = new Location("old fort", "where we could see the port");
            Location Loc4 = new Location("small house", "where an old family lives");
            Location Loc5 = new Location("museum", "which is quite niche");
            Location Loc6 = new Location("stable", "where people raise their finest horses");


            // adding paths
            Path path1 = new Path(new string[] { "north" }, "a trail", " which is where people go every day", Loc1, Loc2);
            Path path2 = new Path(new string[] { "west" }, "main road", " where traders move and go", Loc1, Loc6);
            Path path3 = new Path(new string[] { "east" }, "river bank", " where the weather is quite sunny.", Loc1, Loc3);
            Path path4 = new Path(new string[] { "south" }, "small grove", " near a tiny lake", Loc1, Loc4);
            Path path5 = new Path(new string[] { "northwest" }, "a creek", " where a plan was laid out", Loc1, Loc5);
            Path path6 = new Path(new string[] { "southwest" }, "big street", "near the center of the city", Loc2, Loc3);
            Path path7 = new Path(new string[] { "northeast" }, "a corridor", "near a forest", Loc2, Loc4);
            Path path8 = new Path(new string[] { "southeast" }, "a bridge", "through the great river", Loc2, Loc5);
            Path path9 = new Path(new string[] { "gate" }, "new gate", "leads to stable", Loc2, Loc6);

            //add path to locations.
            Loc1.AddPath(path1);
            Loc1.AddPath(path2);
            Loc1.AddPath(path3);
            Loc1.AddPath(path4);
            Loc1.AddPath(path5);
            Loc2.AddPath(path6);
            Loc2.AddPath(path7);
            Loc2.AddPath(path8);
            Loc2.AddPath(path9);

            Loc1.Inventory.Put(Itm4);
            newPlayer.Location = Loc1;
            newPlayer.Inventory.Put(Itm1);
            newPlayer.Inventory.Put(Itm2);
            newPlayer.Inventory.Put(Itm5);
            newPlayer.Inventory.Put(Bag1);
            Bag1.Inventory.Put(Itm3);

            //handling Command Processor.
            CommandProcessor newCommand = new CommandProcessor();
            TakeCommand      Take       = new TakeCommand();

            newCommand.AddCommand(Take);
            LookCommand Look = new LookCommand();

            newCommand.AddCommand(Look);
            MoveCommand Move = new MoveCommand();

            newCommand.AddCommand(Move);
            PutCommand Put = new PutCommand();

            newCommand.AddCommand(Put);



            while (StayingOpen)
            {
                Console.WriteLine("Please enter command:");
                string   _input  = Console.ReadLine();
                string[] Command = _input.Split();// get help from Charlotte Pierce in HelpDesk.

                if (Command[0] == "quit")
                {
                    Console.WriteLine("Bye.");
                    Thread.Sleep(2000);
                    StayingOpen = false;
                }
                else
                {
                    Console.WriteLine(newCommand.Execute(newPlayer, Command));
                }
            }
        }
コード例 #17
0
        public override GameCommandStatus FixedStep()
        {
            if (_unit != null && _unit.IsAlive)
            {
                //DETERMINES WHETHER UNIT IS ACTUALLY BEING DAMAGED OR HEALED (for reverse effects)
                if (_statChangeData.value < Fix64.Zero)
                {
                    rawValue = _statChangeData.receiver.damageModifier.returnModifiedValue(_statChangeData.value);
                }
                if (_statChangeData.value > Fix64.Zero)
                {
                    rawValue = (Fix64)_statChangeData.value * _statChangeData.receiver.healModifier.returnModifiedValue(_statChangeData.value);
                }


                //UNIT  DAMAGED
                if (rawValue < Fix64.Zero)                  //still have to include max value, make it subtract the correct amount, etc.

                {
                    Fix64 afterArmorDamage = _statChangeData.value * ((Fix64)100 / ((Fix64)100 + _unit.armor.value));
                    //damage is negative, shield is positive so it reduces abs. value
                    Fix64 finalDamage = afterArmorDamage + _unit.shield.value;
                    if (finalDamage <= -_statChangeData.receiver.hP.value)
                    {
                        _unit.hP.addedValueChange(-_statChangeData.receiver.hP.value);                           //weird way to do it, just substracts the amount of health the unit has
//						Debug.Log("dying now");
                        var dieCommand = _dieCommandFactory.Create(_statChangeData);
                        _commandProcessor.AddCommand(dieCommand);
                    }
                    else
                    {
                        if (finalDamage < Fix64.Zero)
                        {
                            _unit.hP.addedValueChange(finalDamage);                               //if unit is not going to die, reduce health by damage amount
                        }
                        else
                        {
                            Debug.Log("shield absorbed the damage");
                        }
                    }

                    _unit.shield.addedValueChange(afterArmorDamage);                      //substracts shield after so it can be used in the health calculation
//					Debug.Log ("Damage for " + finalDamage);

                    //fires the signal here
                    _damageReceiveSignal.Fire(new Signals.GameSignals.DamageReceiveSignal.Data {
                        sender   = _statChangeData.sender,
                        receiver = _statChangeData.receiver,
                        damage   = finalDamage
                    });
                }
                else                     //IF THE UNIT IS BEING HEALED: STILL NEED TO DO THIS PART

                /*
                 * int heal = (int)Mathf.Clamp ((float)_statChangeData.value * (_unit.heal.getMultiplier ()), 0, _unit.maxHp.value - _unit.hP.value);
                 * _unit.hP.addedValueChange (heal);
                 * Debug.Log (heal + "Healed for");
                 */
                {
                    Debug.Log("Tried to heal, healing not implented yet in HPCOMMAND");
                }
            }
            return(GameCommandStatus.Complete);
        }