Ejemplo n.º 1
0
        public void Start () {
            _spriteRenderer = GetComponent<SpriteRenderer>();
            _originalColor = _spriteRenderer.color;
            _enemyModel = new ActorModel(transform.position, InitialHealth);
            _enemyModel.RegisterListener(this);

            _aiController = new EnemyAiController(_enemyModel, 1f, 3f, soundManager);
        }
Ejemplo n.º 2
0
 void Awake()
 {
     mActorModel = gameObject.GetComponent("ActorModel") as ActorModel;
     if (mActorModel == null)
     {
         throw new MissingComponentException("Unable to find actor model on gameObject.");
     }
 }
Ejemplo n.º 3
0
 public void Awake()
 {
     mActorModel = GetComponent("ActorModel") as ActorModel;
     if (mActorModel == null)
     {
         throw new MissingComponentException("Unable to find ActorModel.");
     }
 }
Ejemplo n.º 4
0
		public IActorState Update(ActorModel actorModel, float deltaTime) {
			_timeElapsed += deltaTime;
			if (_timeElapsed < StunDuration) {
				return this;
			} else {
				actorModel.AnimationState = ActorAnimationState.Walking;
				return new ActorWalkState();
			}
		}
Ejemplo n.º 5
0
        public EnemyAiController(ActorModel actorModel, float attackRange, float velocity, Sound soundManager) {
            this._actorModel = actorModel;
            _attackRange = attackRange;
            _velocity = velocity;
			this.soundManager = soundManager;

            PickAiType();
            ResetDecisionTimer();
        }
Ejemplo n.º 6
0
 public IActorState GetHurt(ActorModel actorModel) {
     actorModel.Position -= actorModel.LookDirection * 3f;
     actorModel.Health -= 25f;
     if (actorModel.Health > 5) {
         actorModel.AnimationState = ActorAnimationState.GettingHurt;
         return new ActorStunState(0.2f);
     } else {
         actorModel.AnimationState = ActorAnimationState.Death;
         return GetHurtBadly(actorModel);
     }
 }
Ejemplo n.º 7
0
        // GET: Edit
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ActorModel Actor = _ActorRep.GetActorById(id);

            if (Actor == null)
            {
                return(HttpNotFound());
            }
            return(View(Actor));
        }
Ejemplo n.º 8
0
        public StreamProvider(string name, bool isRewindable)
        {
            this.name         = name;
            this.isRewindable = isRewindable;
            if (StreamDictionaryMachineID == null)
            {
                StreamDictionaryMachineID = ActorModel.Runtime.CreateMachine(typeof(StreamDictionaryMachine));
            }

            ActorModel.RegisterCleanUpAction(() =>
            {
                StreamDictionaryMachineID = null;
            });
        }
Ejemplo n.º 9
0
        // GET: ActorModels/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ActorModel actorModel = db.ActorModels.Find(id);

            if (actorModel == null)
            {
                return(HttpNotFound());
            }
            return(View(actorModel));
        }
Ejemplo n.º 10
0
    protected ActorModel GetModel(int index, ExteriorArithmeticUnit exteriorUnit)
    {
        ActorModel actorModel = ModelPool.Instance.Get(exteriorUnit.FinalModelID);

        actorModel.ModelType  = ActorModelType.UI;
        actorModel.ModelLayer = "NPC";
        actorModel.set_name(index.ToString());
        actorModel.get_transform().set_position(new Vector3((float)(-1000 * (index + 1)), 1000f, 0f));
        actorModel.EquipOn(exteriorUnit.FinalWeaponID, exteriorUnit.FinalWeaponGogok);
        actorModel.EquipOn(exteriorUnit.FinalClothesID, 0);
        actorModel.EquipWingOn(exteriorUnit.FinalWingID);
        LayerSystem.SetGameObjectLayer(actorModel.get_gameObject(), "NPC", 1);
        actorModel.PreciseSetAction("idle_city");
        return(actorModel);
    }
Ejemplo n.º 11
0
 public ActorController(
     ActorSettings settings,
     ActorModel model,
     MoveHandler moveHandler,
     InteractHandler interactHandler,
     PushHandler pushHandler,
     ResetHandler resetHandler)
 {
     _settings        = settings;
     _model           = model;
     _moveHandler     = moveHandler;
     _interactHandler = interactHandler;
     _pushHandler     = pushHandler;
     _resetHandler    = resetHandler;
 }
Ejemplo n.º 12
0
        /// <summary>
        /// Constructor. Grain implementers do not have to expose this
        /// constructor but can choose to do so. This constructor is
        /// particularly useful for unit testing where test code can
        /// create a Grain and replace the IGrainIdentity and IGrainRuntime
        /// with test doubles.
        /// </summary>
        /// <param name="identity">IGrainIdentity</param>
        /// <param name="runtime">IGrainRuntime</param>
        protected Grain(IGrainIdentity identity, IGrainRuntime runtime)
        {
            this.Identity = identity;
            this.Runtime  = runtime;
            if (StreamProviderDictionaryMachineId == null)
            {
                StreamProviderDictionaryMachineId = ActorModel.Runtime.CreateMachine(
                    typeof(StreamProviderDictionaryMachine), "StreamProviderDictionaryMachine");
            }

            ActorModel.RegisterCleanUpAction(() =>
            {
                StreamProviderDictionaryMachineId = null;
            });
        }
Ejemplo n.º 13
0
        static void Main(string[] args)
        {
            var        obj = ActorProxy.Create <IHuman>(new ActorId(2), "ABC");
            Task <int> t   = obj.Eat(9, 2, "qwer");
            int        x   = ActorModel.GetResult <int>(t);

            Console.WriteLine(x);

            //var obj = new HumanProxy(PSharpRuntime.Create());
            //Task<int> t = obj.Eat(10, 97, "asdf");
            //int x = ActorModel.GetResult<int>(t);
            //Console.WriteLine(x);

            Console.ReadLine();
        }
Ejemplo n.º 14
0
        public IActionResult ChooseRace()
        {
            if (HasCharacter())
            {
                return(RedirectToAction("EditStats"));
            }

            var actor = new ActorModel()
            {
                Name = Context.User.Identity.Name
            };

            ViewBag.Races = KatanaMUD.Game.Data.RaceTemplates.ToList();
            return(View(actor));
        }
Ejemplo n.º 15
0
        public string AddTrack(TrackCreateCommand createTrack)
        {
            WithValidation(() => CommandValidator.Validate(createTrack));
            var trackId      = Guid.NewGuid().ToString();
            var trackCreated = new TrackCreated
            {
                Binary    = createTrack.Binary,
                OwnerId   = createTrack.OwnerId,
                Timestamp = createTrack.Timestamp,
                TrackId   = trackId,
            };

            ActorModel.Tell(ActorModel.TrackPapaPath, trackCreated);
            return(trackId);
        }
Ejemplo n.º 16
0
        public async Task AccessSafe()
        {
            bool isSafeOpen = await this.StateManager.GetStateAsync <bool>("IsSafeOpen");

            if (isSafeOpen)
            {
                ActorModel.Log("[LOG] The safe is closed.");
                await this.StateManager.SetStateAsync("IsSafeOpen", false);
            }
            else
            {
                ActorModel.Log("[LOG] The safe is open.");
                await this.StateManager.SetStateAsync("IsSafeOpen", true);
            }
        }
Ejemplo n.º 17
0
        //IGrainReminder myReminder;
        //public override async Task OnActivateAsync()
        //{
        //var reminderTask = this.RegisterOrUpdateReminder("helloReminder", TimeSpan.FromSeconds(2),
        //    TimeSpan.FromSeconds(0));
        //ActorModel.Wait(reminderTask);
        //myReminder = ActorModel.GetResult<IGrainReminder>(reminderTask);
        ////this.Timer = this.RegisterTimer(HandleTimeout, null,
        ////    TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(0));
        //    await base.OnActivateAsync();
        //}

        public async Task DoSomething(int numberOfItems)
        {
            var receiver = GrainClient.GrainFactory.GetGrain <IReceiver>(1);

            await receiver.StartTransaction();

            for (int i = 0; i < numberOfItems; i++)
            {
                await receiver.TransmitData(new TransactionItems("xyz" + i));
            }

            int transmitted = await receiver.GetCurrentCount();

            ActorModel.Assert(transmitted <= numberOfItems, "Items sent: " + numberOfItems + "; Transmitted: " + transmitted);
        }
Ejemplo n.º 18
0
        public Task ProcessResponse()
        {
            ActorModel.Log($"<RaftLog> Client received a response.");

            if (this.RequestTimer != null)
            {
                this.RequestTimer.Dispose();
                this.RequestTimer = null;
            }

            this.RequestTimer = this.RegisterTimer(PumpRequest, null,
                                                   TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(5));

            return(TaskDone.Done);
        }
Ejemplo n.º 19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommentViewModel"/> class.
 /// </summary>
 /// <param name="thread">The thread that the comment is a part of.</param>
 /// <param name="currentUser">The current user.</param>
 /// <param name="model">The comment model.</param>
 protected CommentViewModel(
     ICommentThreadViewModel thread,
     ActorModel currentUser,
     CommentModel model)
     : this(
         thread,
         new ActorViewModel(currentUser),
         model.Id,
         model.Body,
         CommentEditState.None,
         new ActorViewModel(model.Author),
         model.CreatedAt,
         new Uri(model.Url))
 {
 }
Ejemplo n.º 20
0
    public override void TakeMsg(ActorModel who, EventMsg msg)
    {
        switch (msg.Type)
        {
        case EventType.GetBumped:
            God.C.AddAction(new BumpAction(msg.Source, who.Location.x, who.Location.y));
            msg.Source.TakeMsg(new EventMsg(EventType.TakeDmg, who, God.Library.GetMonster(who.Species).Damage));
            who.Despawn();
            return;

        case EventType.GetName:
            msg.Text += " " + God.Library.GetMonster(who.Species).Type;
            return;
        }
    }
Ejemplo n.º 21
0
        public Task RelayClientRequest(int clientId, int command)
        {
            ActorModel.Log($"<RaftLog> ClusterManager is relaying client request " + command + "\n");

            if (this.Leader != null)
            {
                this.Leader.ProcessClientRequest(clientId, command);
            }
            else
            {
                this.Cluster.RedirectClientRequest(clientId, command);
            }

            return(TaskDone.Done);
        }
Ejemplo n.º 22
0
 public Task <Location> GotoRoom()
 {
     if (ActorModel.Random())
     {
         return(Task.FromResult(Location.Garden));
     }
     else if (ActorModel.Random())
     {
         return(Task.FromResult(Location.Kitchen));
     }
     else
     {
         return(Task.FromResult(Location.Bedroom));
     }
 }
Ejemplo n.º 23
0
    private new void Awake()
    {
        base.Awake();
#if UNITY_EDITOR
        if (ActorModel.Model == null)
        {
            ActorModel.CreateModel();
        }
        GameStaticMethod.GameInit();
#endif

        enemySpawners = GetComponentsInChildren <EnemySpawn>();
        SpawnEnemys();

        GetView <GameInfoView>().SetTipText("第" + level + "层");
    }
Ejemplo n.º 24
0
        public void InsertOrUpdate(ActorModel actor)
        {
            var actorEntity = _mapper.Map <Actor>(actor);

            if (actorEntity.Id == Guid.Empty)
            {
                actorEntity.Id        = Guid.NewGuid();
                actorEntity.CreatedAt = DateTime.Now;
                _uow.Get <Actor>().Add(actorEntity);
            }
            else
            {
                actorEntity.LastModifiedAt = DateTime.Now;
                _uow.Get <Actor>().Update(actorEntity);
            }
        }
Ejemplo n.º 25
0
        /// <summary>
        /// 新增明細
        /// </summary>
        /// <param name="detail"></param>
        /// <returns></returns>
        public bool AddDetail(DetailViewModel detail)
        {
            #region 參數宣告
            bool             result  = false;
            ActorModel       actor   = new ActorModel();
            IActorRepository actorRp = new ActorRepository();
            #endregion

            #region 流程
            actor  = PropertyCopy.Convert <DetailViewModel, ActorModel>(detail);
            result = actorRp.AddActor(actor);

            return(result);

            #endregion
        }
Ejemplo n.º 26
0
    public static ActorModel GetModel(int wingModelId)
    {
        ActorModel actorModel = ModelPool.Instance.Get(EntityWorld.Instance.EntSelf.ModelID);

        actorModel.ModelType  = ActorModelType.UI;
        actorModel.ModelLayer = "NPC";
        float num = (float)(-1000 * (WingGlobal.models.get_Count() + 1));

        actorModel.get_transform().set_position(new Vector3(num, 0f));
        actorModel.EquipOn(EntityWorld.Instance.EntSelf.EquipCustomizationer.GetIdOfWeapon(), 0);
        actorModel.EquipOn(EntityWorld.Instance.EntSelf.EquipCustomizationer.GetIdOfClothes(), 0);
        actorModel.EquipWingOn(wingModelId);
        LayerSystem.SetGameObjectLayer(actorModel.get_gameObject(), "NPC", 1);
        actorModel.ShowSelf(true);
        return(actorModel);
    }
Ejemplo n.º 27
0
        private Task PumpRequest(object args)
        {
            if (this.RequestTimer != null)
            {
                this.RequestTimer.Dispose();
                this.RequestTimer = null;
            }

            this.LatestCommand = new Random().Next(100);

            ActorModel.Log($"<RaftLog> Client is sending new request {this.LatestCommand}.");

            this.ClusterManager.RelayClientRequest(6, this.LatestCommand);

            return(TaskDone.Done);
        }
            public async Task CanBeExecutedForCommentsByTheSameAuthor()
            {
                var session = CreateSession();
                var thread  = CreateThread();

                var currentUser = new ActorModel {
                    Login = "******"
                };
                var comment = new PullRequestReviewCommentModel {
                    Author = currentUser
                };

                var target = await CreateTarget(session, null, thread, currentUser, null, comment);

                Assert.That(target.BeginEdit.CanExecute(new object()), Is.True);
            }
Ejemplo n.º 29
0
        //protected override Task OnActivateAsync()
        //{
        //    (this as IActor1).Foo();
        //    return base.OnActivateAsync();
        //}

        public Task Foo()
        {
            var actor2Proxy = ActorProxy.Create <IActor2>(new ActorId(1), "A2");
            int val         = 9;
            var t           = actor2Proxy.SetValue(val, this);

            Console.WriteLine("Actor1 is waiting for set value from Actor2");
            //ActorModel.Wait(t);

            Task <int> s = actor2Proxy.GetValue();
            var        r = ActorModel.GetResult <int>(s);

            Console.WriteLine(r);

            return(Task.FromResult(true));
        }
Ejemplo n.º 30
0
        public Entity GetWorld()
        {
            if (world == null)
            {
                ActorModel worldActor = new ActorModel();
                worldActor.uid = -999;
                worldActor.id  = -999;

                GameObject worldGo  = new GameObject("<------------EntityWorld---------->");
                ActorObj   actorObj = worldGo.AddComponent <ActorObj>();
                actorObj.Init(worldActor, -999);

                world = GetEntity(-999);
            }
            return(world);
        }
Ejemplo n.º 31
0
        public static ActorModel ToModel(this Actor entity)
        {
            if (entity == null)
            {
                return(null);
            }

            var model = new ActorModel
            {
                Id   = entity.Id,
                Name = entity.Name,
                Imdb = entity.Imdb,
            };

            return(model);
        }
Ejemplo n.º 32
0
        private Task RedirectClientRequest(object args)
        {
            var request = (Tuple <int, int>)args;

            if (this.RetryTimer != null)
            {
                this.RetryTimer.Dispose();
                this.RetryTimer = null;
            }

            ActorModel.Log($"<RaftLog> ClusterManager is redirecting client request " + request.Item2 + "\n");

            this.Cluster.RelayClientRequest(request.Item1, request.Item2);

            return(TaskDone.Done);
        }
Ejemplo n.º 33
0
 public IHttpActionResult AddNewActor(ActorModel actor)
 {
     try
     {
         if (actor == null || !ModelState.IsValid)
         {
             return(BadRequest(ModelState));
         }
         actorService.AddNewActor(actor);
     }
     catch (Exception ex)
     {
         return(InternalServerError());
     }
     return(new MyMessageResult("New Actor Successfully", Request));
 }
Ejemplo n.º 34
0
        public StatsPanel(ContentManager content, ActorModel player, Vector2 position)
        {
            _font = content.Load <SpriteFont>("Fonts/ButtonFont");

            _player = player;

            _position = position;

            var displayPictureTexture = content.Load <Texture2D>("AfterBattle/DisplayPicture");

            _displayPicture = new Sprite(displayPictureTexture)
            {
                Position = position + new Vector2((displayPictureTexture.Width / 2) - 10, (displayPictureTexture.Height / 2) + 30),
                Opacity  = 0f,
            };
        }
Ejemplo n.º 35
0
        public static void Execute(PSharpRuntime runtime)
        {
            //Configuration conf = Configuration.Create(true, true, true, true, true);
            //ActorModel.Configure(conf);

            ActorModel.Start(runtime, () =>
            {
                var config = ClientConfiguration.LocalhostSilo();
                GrainClient.Initialize(config);

                runtime.RegisterMonitor(typeof(SafetyMonitor));

                var clusterManager = GrainClient.GrainFactory.GetGrain <IClusterManager>(0);
                clusterManager.Configure();
            });
        }
Ejemplo n.º 36
0
        /// <summary>
        /// Static constructor.
        /// </summary>
        static GrainClient()
        {
            GrainClient.GrainFactory = new GrainFactory();
            GrainClient.Runtime      = new GrainRuntime(GrainClient.GrainFactory);

            string assemblyPath = Path.GetDirectoryName(Assembly.GetCallingAssembly().Location);

            ProxyFactory = ActorModel.Runtime.CreateMachine(typeof(OrleansGrainFactory),
                                                            new ActorFactory.InitEvent(assemblyPath));

            ActorModel.RegisterCleanUpAction(() =>
            {
                ProxyFactory = ActorModel.Runtime.CreateMachine(typeof(OrleansGrainFactory),
                                                                new ActorFactory.InitEvent(assemblyPath));
            });
        }
Ejemplo n.º 37
0
 public abstract IActorState LookTowards(ActorModel actorModel, Vector2 direction);
Ejemplo n.º 38
0
 public override IActorState Jump(ActorModel actorModel) {
     return this;
 }
Ejemplo n.º 39
0
 public abstract IActorState Move(ActorModel actorModel, Vector2 position);
Ejemplo n.º 40
0
 public override IActorState Jump(ActorModel actorModel) {
     throw new System.NotImplementedException();
 }
Ejemplo n.º 41
0
 public abstract IActorState Update(ActorModel actorModel, float deltaTime);
Ejemplo n.º 42
0
 public override IActorState Attack(ActorModel actorModel) {
     actorModel.AnimationState = ActorAnimationState.Attacking;
     return new ActorAttackState();
 }
Ejemplo n.º 43
0
 public override IActorState Update(ActorModel actorModel, float deltaTime) {
     return this;
 }
Ejemplo n.º 44
0
 public override IActorState Move(ActorModel actorModel, Vector2 position) {
     actorModel.Position += position;
     return this;
 }
Ejemplo n.º 45
0
 public abstract IActorState Attack(ActorModel actorModel);
Ejemplo n.º 46
0
 public virtual void Start() {
     ActorModel = new ActorModel(transform.position, 100f);
     ActorModel.RegisterListener(this);
 }
Ejemplo n.º 47
0
 public abstract IActorState Jump(ActorModel actorModel);
Ejemplo n.º 48
0
		public IActorState Attack(ActorModel actorModel) {
			return this;
		}
Ejemplo n.º 49
0
		public IActorState LookTowards(ActorModel actorModel, Vector2 direction) {
			return this;
		}
Ejemplo n.º 50
0
		public IActorState GetHurtBadly(ActorModel actorModel) {
			return this;
		}
Ejemplo n.º 51
0
 public override IActorState LookTowards(ActorModel actorModel, Vector2 direction) {
     actorModel.LookDirection = direction;
     return this;
 }
Ejemplo n.º 52
0
		public IActorState Move(ActorModel actorModel, Vector2 position) {
			return this;
		}
Ejemplo n.º 53
0
 public override IActorState Attack(ActorModel actorModel) {
     return this;
 }
Ejemplo n.º 54
0
		public IActorState Jump(ActorModel actorModel) {
			return this;
		}