コード例 #1
0
 private void Awake()
 {
     mover          = GetComponent <Mover>();
     actionSchedule = GetComponent <ActionSchedule>();
     animator       = GetComponent <Animator>();
     baseStats      = GetComponent <BaseStats>();
 }
コード例 #2
0
        public static bool SaveActionSchedule(ActionSchedule schedule)
        {
            var successfullySaved = false;
            var schedules         = GetActionSchedules(schedule.AppName);
            var existingSchedule  = schedules.FirstOrDefault(s => s.ActionName == schedule.ActionName);

            if (existingSchedule != null)
            {
                //delete existing schedule
                schedules.Remove(existingSchedule);
            }
            schedules.Add(schedule);

            var filePath = GetFilePath(schedule.AppName);

            if (filePath != null)
            {
                var json = JsonConvert.SerializeObject(schedules, Formatting.Indented);
                File.WriteAllText(filePath, json);
                successfullySaved = true;
            }

            //todo: return false if anything goes wrong
            return(successfullySaved);
        }
コード例 #3
0
 void Awake()
 {
     navMeshAgent   = GetComponent <NavMeshAgent>();
     animator       = GetComponent <Animator>();
     actionSchedule = GetComponent <ActionSchedule>();
     health         = GetComponent <Health>();
 }
コード例 #4
0
ファイル: AIController.cs プロジェクト: MrEk0/RPG
 private void Awake()
 {
     player         = GameObject.FindGameObjectWithTag("Player");
     fighter        = GetComponent <Fighter>();
     health         = GetComponent <Health>();
     mover          = GetComponent <Mover>();
     actionSchedule = GetComponent <ActionSchedule>();
 }
コード例 #5
0
ファイル: AIController.cs プロジェクト: GDanielf/RPG-Unity
        private void Awake()
        {
            mover          = GetComponent <Mover>();
            fighter        = GetComponent <Fighter>();
            health         = GetComponent <Health>();
            actionSchedule = GetComponent <ActionSchedule>();
            player         = GameObject.FindWithTag("Player");

            guardPosition = new LazyValue <Vector3>(GetGuardPosition);
        }
コード例 #6
0
        /// <summary>
        /// 行動できるプレイヤーを次に進める
        /// </summary>
        private void IncrementTurn()
        {
            if (NoEnqueue)
            {
                NoEnqueue = false;
                return;
            }

            ActionSchedule.Enqueue(ActionSchedule.Dequeue());
            MatchInfo.NextPlayerID = ActionSchedule.Peek();
        }
コード例 #7
0
        public ActionSchedule Create(ActionSchedule schedule)
        {
            if (schedule.ActionId == 0)
            {
                throw new ArgumentException("Action ID is missing.");
            }

            int accountId = schedule.AccountId > 0 ? schedule.AccountId : CurrentAccount;

            return(Create(accountId, schedule.ActionId, schedule));
        }
コード例 #8
0
        public void Delete(ActionSchedule schedule)
        {
            if (schedule.ActionId == 0)
            {
                throw new ArgumentException("Action ID is missing.");
            }
            if (schedule.Id == 0)
            {
                throw new ArgumentException("Schedule ID is missing.");
            }

            int accountId = schedule.AccountId > 0 ? schedule.AccountId : CurrentAccount;

            Delete(accountId, schedule.ActionId, schedule.Id);
        }
コード例 #9
0
ファイル: Scheduler.cs プロジェクト: ErikHen/AF_NetCoreLab
        private bool ShouldActionBeScheduled(ActionSchedule actionSchedule)
        {
            if (actionSchedule.NextRun == DateTime.MinValue)
            {
                return(false);
            }
            if (actionSchedule.StopDateTime == DateTime.MinValue)
            {
                return(true);
            }
            if (actionSchedule.StopDateTime > DateTime.UtcNow)
            {
                return(true);
            }

            return(false);
        }
コード例 #10
0
        public ActionTimer(ActionSchedule actionSchedule)
        {
            var state = new TimerState(actionSchedule);

            var dueTime = TimeSpan.FromSeconds(1); //one second

            if (actionSchedule.NextRun > DateTime.UtcNow)
            {
                dueTime = actionSchedule.NextRun - DateTime.UtcNow;
            }

            // Create a timer. The timer fires once, and gets a new due-time when the action has finished running.
            var timer = new Timer(RunScheduledAction, state, dueTime, TimeSpan.FromMilliseconds(-1)); //-1 disables periodic runs

            // Keep a handle to the timer, so it can be disposed.
            state.Timer = timer;
        }
コード例 #11
0
 /// <summary>
 /// 試合を開始する処理
 /// </summary>
 public void Start()
 {
     MatchInfo.Turn++;
     MatchInfo.NextPlayerID = ActionSchedule.Peek();
 }
コード例 #12
0
        public ActionSchedule Create(int actionId, ActionSchedule schedule)
        {
            int accountId = schedule.AccountId > 0 ? schedule.AccountId : CurrentAccount;

            return(Create(accountId, actionId, schedule));
        }
コード例 #13
0
        public ActionSchedule Create(int accountId, int actionId, ActionSchedule schedule)
        {
            var rval = TDClient.Add(LIST, new { accountId, actionId }, schedule);

            return(rval);
        }
コード例 #14
0
 public TimerState(ActionSchedule actionSchedule)
 {
     Counter        = 0;
     IsRunning      = false;
     ActionSchedule = actionSchedule;
 }
コード例 #15
0
 public ActionSchedule Create(int accountId, int actionId, ActionSchedule schedule)
 {
     return(Api.Post($"/account/{accountId}/action/{actionId}/schedule", schedule));
 }
コード例 #16
0
        public ActionSchedule Update(int accountId, int actionId, int scheduleId, ActionSchedule schedule)
        {
            var rval = TDClient.Update(ITEM, new { accountId, actionId, scheduleId }, schedule);

            return(rval);
        }
コード例 #17
0
 public ActionSchedule Update(int accountId, int actionId, int scheduleId, ActionSchedule schedule)
 {
     return(Api.Put($"/account/{accountId}/action/{actionId}/schedule/{scheduleId}", schedule));
 }
コード例 #18
0
 public ActionSchedule Update(int actionId, int scheduleId, ActionSchedule schedule)
 {
     return(Update(CurrentAccount, actionId, scheduleId, schedule));
 }
コード例 #19
0
ファイル: Timer.cs プロジェクト: MrHungerrr/EXaM
 public Timer(int time)
 {
     _timeGeneral = time;
     _schedule    = new ActionSchedule(this);
 }