Exemple #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);
        }
Exemple #2
0
 void Awake()
 {
     mActorModel = gameObject.GetComponent("ActorModel") as ActorModel;
     if (mActorModel == null)
     {
         throw new MissingComponentException("Unable to find actor model on gameObject.");
     }
 }
Exemple #3
0
 public void Awake()
 {
     mActorModel = GetComponent("ActorModel") as ActorModel;
     if (mActorModel == null)
     {
         throw new MissingComponentException("Unable to find ActorModel.");
     }
 }
Exemple #4
0
		public IActorState Update(ActorModel actorModel, float deltaTime) {
			_timeElapsed += deltaTime;
			if (_timeElapsed < StunDuration) {
				return this;
			} else {
				actorModel.AnimationState = ActorAnimationState.Walking;
				return new ActorWalkState();
			}
		}
        public EnemyAiController(ActorModel actorModel, float attackRange, float velocity, Sound soundManager) {
            this._actorModel = actorModel;
            _attackRange = attackRange;
            _velocity = velocity;
			this.soundManager = soundManager;

            PickAiType();
            ResetDecisionTimer();
        }
Exemple #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);
     }
 }
Exemple #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));
        }
        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;
            });
        }
Exemple #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));
        }
Exemple #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);
    }
 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;
 }
Exemple #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;
            });
        }
Exemple #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();
        }
Exemple #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));
        }
Exemple #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);
        }
Exemple #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);
            }
        }
Exemple #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);
        }
Exemple #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);
        }
 /// <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))
 {
 }
Exemple #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;
        }
    }
        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);
        }
Exemple #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));
     }
 }
Exemple #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 + "层");
    }
Exemple #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);
            }
        }
Exemple #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
        }
Exemple #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);
    }
Exemple #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);
            }
Exemple #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));
        }
Exemple #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);
        }
Exemple #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);
        }
        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);
        }
 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));
 }
Exemple #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,
            };
        }
Exemple #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();
            });
        }
Exemple #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));
            });
        }
Exemple #37
0
 public abstract IActorState LookTowards(ActorModel actorModel, Vector2 direction);
 public override IActorState Jump(ActorModel actorModel) {
     return this;
 }
Exemple #39
0
 public abstract IActorState Move(ActorModel actorModel, Vector2 position);
Exemple #40
0
 public override IActorState Jump(ActorModel actorModel) {
     throw new System.NotImplementedException();
 }
Exemple #41
0
 public abstract IActorState Update(ActorModel actorModel, float deltaTime);
Exemple #42
0
 public override IActorState Attack(ActorModel actorModel) {
     actorModel.AnimationState = ActorAnimationState.Attacking;
     return new ActorAttackState();
 }
Exemple #43
0
 public override IActorState Update(ActorModel actorModel, float deltaTime) {
     return this;
 }
Exemple #44
0
 public override IActorState Move(ActorModel actorModel, Vector2 position) {
     actorModel.Position += position;
     return this;
 }
Exemple #45
0
 public abstract IActorState Attack(ActorModel actorModel);
Exemple #46
0
 public virtual void Start() {
     ActorModel = new ActorModel(transform.position, 100f);
     ActorModel.RegisterListener(this);
 }
Exemple #47
0
 public abstract IActorState Jump(ActorModel actorModel);
Exemple #48
0
		public IActorState Attack(ActorModel actorModel) {
			return this;
		}
Exemple #49
0
		public IActorState LookTowards(ActorModel actorModel, Vector2 direction) {
			return this;
		}
Exemple #50
0
		public IActorState GetHurtBadly(ActorModel actorModel) {
			return this;
		}
Exemple #51
0
 public override IActorState LookTowards(ActorModel actorModel, Vector2 direction) {
     actorModel.LookDirection = direction;
     return this;
 }
Exemple #52
0
		public IActorState Move(ActorModel actorModel, Vector2 position) {
			return this;
		}
 public override IActorState Attack(ActorModel actorModel) {
     return this;
 }
Exemple #54
0
		public IActorState Jump(ActorModel actorModel) {
			return this;
		}