Exemplo n.º 1
0
 private void Awake()
 {
     mover          = GetComponent <Mover>();
     actionSchedule = GetComponent <ActionSchedule>();
     animator       = GetComponent <Animator>();
     baseStats      = GetComponent <BaseStats>();
 }
        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);
        }
Exemplo n.º 3
0
 void Awake()
 {
     navMeshAgent   = GetComponent <NavMeshAgent>();
     animator       = GetComponent <Animator>();
     actionSchedule = GetComponent <ActionSchedule>();
     health         = GetComponent <Health>();
 }
Exemplo n.º 4
0
 private void Awake()
 {
     player         = GameObject.FindGameObjectWithTag("Player");
     fighter        = GetComponent <Fighter>();
     health         = GetComponent <Health>();
     mover          = GetComponent <Mover>();
     actionSchedule = GetComponent <ActionSchedule>();
 }
Exemplo n.º 5
0
        private void Awake()
        {
            mover          = GetComponent <Mover>();
            fighter        = GetComponent <Fighter>();
            health         = GetComponent <Health>();
            actionSchedule = GetComponent <ActionSchedule>();
            player         = GameObject.FindWithTag("Player");

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

            ActionSchedule.Enqueue(ActionSchedule.Dequeue());
            MatchInfo.NextPlayerID = ActionSchedule.Peek();
        }
Exemplo n.º 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));
        }
Exemplo n.º 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);
        }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 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;
        }
Exemplo n.º 11
0
 /// <summary>
 /// 試合を開始する処理
 /// </summary>
 public void Start()
 {
     MatchInfo.Turn++;
     MatchInfo.NextPlayerID = ActionSchedule.Peek();
 }
Exemplo n.º 12
0
        public ActionSchedule Create(int actionId, ActionSchedule schedule)
        {
            int accountId = schedule.AccountId > 0 ? schedule.AccountId : CurrentAccount;

            return(Create(accountId, actionId, schedule));
        }
Exemplo n.º 13
0
        public ActionSchedule Create(int accountId, int actionId, ActionSchedule schedule)
        {
            var rval = TDClient.Add(LIST, new { accountId, actionId }, schedule);

            return(rval);
        }
Exemplo n.º 14
0
 public TimerState(ActionSchedule actionSchedule)
 {
     Counter        = 0;
     IsRunning      = false;
     ActionSchedule = actionSchedule;
 }
Exemplo n.º 15
0
 public ActionSchedule Create(int accountId, int actionId, ActionSchedule schedule)
 {
     return(Api.Post($"/account/{accountId}/action/{actionId}/schedule", schedule));
 }
Exemplo n.º 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);
        }
Exemplo n.º 17
0
 public ActionSchedule Update(int accountId, int actionId, int scheduleId, ActionSchedule schedule)
 {
     return(Api.Put($"/account/{accountId}/action/{actionId}/schedule/{scheduleId}", schedule));
 }
Exemplo n.º 18
0
 public ActionSchedule Update(int actionId, int scheduleId, ActionSchedule schedule)
 {
     return(Update(CurrentAccount, actionId, scheduleId, schedule));
 }
Exemplo n.º 19
0
 public Timer(int time)
 {
     _timeGeneral = time;
     _schedule    = new ActionSchedule(this);
 }