예제 #1
0
        private static IDictionary <string, PropertyMetaData> GetProperties(VisitorState state, IReflect classType, object source)
        {
            var className = classType.UnderlyingSystemType.Name;

            foreach (var property in classType.GetProperties(BindingFlags.Public | BindingFlags.Instance))
            {
                var value = property.GetValue(source);
                var key   = className + "." + property.Name;

                if (property.PropertyType.IsPrimtiveType())
                {
                    if (state.CanVisit(key))
                    {
                        state.Placeholders.Add(key, GetPropertyMetaData(property, value));
                    }
                }
                else if (state.CanVisit(value))
                {
                    state.Visited.Add(value);
                    GetProperties(state, property.PropertyType, value);
                }
            }

            return(state.Placeholders);
        }
예제 #2
0
        public static IDictionary <string, PropertyMetaData> GetProperties <T>(this T source)
        {
            if (source == null)
            {
                ThrowExceptionWhenSourceArgumentIsNull();
            }

            var state = new VisitorState();

            return(GetProperties(state, typeof(T), source));
        }
 // Start is called before the first frame update
 void Start()
 {
     animator      = GetComponentInChildren <Animator>();
     state         = VisitorState.Idle;
     player        = GameObject.FindWithTag("Player");
     rb            = GetComponent <Rigidbody>();
     agent         = GetComponent <NavMeshAgent>();
     visitorScript = GetComponent <VisitorScript>();
     baseSpeed     = agent.speed;
     StartCoroutine(CheckPropStates());
 }
 void RunAway()
 {
     if (totalFear >= fearThreshold)
     {
         //agent.destination = exit.position;
         state = VisitorState.FleeingBuilding;
     }
     else
     {
         //TODO: Run out of current room
         state = VisitorState.FleeingRoom;
     }
 }
예제 #5
0
        public ActionResult GetEventDetails(string EventKey, string referralid = "")
        {
            var eventdata = EventService.GetEventByKey(EventKey);

            if (referralid != "")
            {
                var visitorstate = new VisitorState();
                visitorstate.IPaddress   = "";
                visitorstate.CreatedDate = DateTime.Now;
                visitorstate.ReferralId  = Convert.ToInt32(referralid);
                RegisteredUserService.InsertVisitorState(visitorstate);
            }
            return(Json(new { success = true, form = eventdata.FormBuilderCode, eventid = eventdata.EventId, buttonUrl = eventdata.ButtonURL, fbButtonUrl = eventdata.FbButtonURL, domainname = eventdata.DomainName }));
        }
예제 #6
0
        protected override IEnumerable <DbParameter> GetDbParameters(VisitorState state)
        {
            // we have a list of parameters, some of them are duplicates
            // some contain type, some not
            // we need to get a final list, preferable with types

            return(state.Parameters
                   .GroupBy(p => p.Name)
                   .Select(pg => pg.FirstOrDefault(p => p.DbType.HasValue) ?? pg.First())
                   .Except(state.Variables, ParameterEqualityComparer.Default)
                   .Select(p =>
            {
                var sp = new MySqlParameter
                {
                    ParameterName = p.Name,
                    Direction = p.Direction
                };
                if (p.DbType.HasValue)
                {
                    sp.DbType = CommonDbTypeToDbType[p.DbType.Value];
                }
                if (p.Length.HasValue)
                {
                    sp.Size = p.Length.Value;
                }

                var value = state.ParameterValues.FirstOrDefault(pp => string.Equals(pp.Name, p.Name));
                if (value != null && value.Value != null)
                {
                    sp.Value = value.Value;
                }
                else if (p.DefaultValue != null)
                {
                    sp.Value = p.DefaultValue;
                }
                return sp;
            }));
        }
    // Update is called once per frame
    void Update()
    {
        if (totalFear > fearThreshold)
        {
            animator.SetInteger("Shookiness", 1);
        }

        if (state == VisitorState.Idle)
        {
            GetNewInterestItem();
            if (currentInterestItem != null)
            {
                agent.destination = currentInterestItem.GetStandPosition();
                state             = VisitorState.MovingToObserve;
                agent.speed       = baseSpeed;
            }
        }
        else if (state == VisitorState.MovingToObserve)
        {
            if (!agent.pathPending && agent.remainingDistance < 0.5f)
            {
                agent.ResetPath();
                state = VisitorState.Observing;
                startedObservingTimestamp = Time.time;
            }
            agent.speed = baseSpeed;
        }
        else if (state == VisitorState.Observing)
        {
            transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.LookRotation(currentInterestItem.GetLookDirection(), Vector3.up), 0.2f);
            if (Time.time - startedObservingTimestamp > interestDuration)
            {
                GetNewInterestItem();
                agent.destination = currentInterestItem.GetStandPosition();
                state             = VisitorState.MovingToObserve;
            }
            agent.speed = baseSpeed;
        }
        else if (state == VisitorState.FleeingRoom)
        {
            if (!agent.pathPending && agent.remainingDistance < 0.5f)
            {
                agent.ResetPath();
                state = VisitorState.Idle;
            }
            agent.speed = baseSpeed * 1.5f;
            animator.SetInteger("Shookiness", 2);
        }
        else if (state == VisitorState.FleeingBuilding)
        {
            agent.ResetPath();
            rb.isKinematic = false;
            Vector3 direction = Vector3.zero;
            direction += -visitorScript.LocalGradient().normalized;
            if (!player.GetComponent <PlayerInvisibility>().isInvisible)
            {
                Vector3 playerOffset = transform.position - player.transform.position;
                direction += playerOffset.normalized;
            }
            Vector3 exitOffset = exit.position - transform.position;
            direction += exitOffset.normalized * 2.5f;
            Debug.Log(direction);
            //rb.AddForce(force);
            rb.velocity = direction.normalized * baseSpeed;

            animator.SetInteger("Shookiness", 2);

            if ((transform.position - exit.position).magnitude < 5f)
            {
                Destroy(gameObject);
            }

            //if (!agent.pathPending && agent.remainingDistance < 0.5f)
            //{
            //    agent.ResetPath();
            //    Destroy(gameObject);
            //}
            //agent.speed = baseSpeed * 1.5f;
        }
    }
예제 #8
0
 public static void InsertVisitorState(VisitorState visitorstate)
 {
     db.VisitorStates.Add(visitorstate);
     db.SaveChanges();
 }
 public static IEnumerable<CXCursor> GetChildren(this CXCursor cursor)
 {
     var state = new VisitorState ();
     clang.visitChildren(cursor, state.VisitorCallback, new CXClientData());
     return state.Children;
 }
        /// <summary>
        /// Resets AI after they are done being spooked
        /// </summary>
        void ResolveSpook()
        {
            currentSpookDuration = 0f;

            if (currentSpook <= faintThreshold)
            {
                currentVisitorState = VisitorState.FAINTED;
            }
            else if (currentSpook <= 0)
            {
                currentVisitorState = VisitorState.LEAVING;
            }
            else
            {
                currentVisitorState = VisitorState.GOING_TO_ATTACK;
            }
        }
 /// <summary>
 /// Handles what happens when you spook a visitor even slightly
 /// </summary>
 public void SpookAnAmount(int scareAmount)
 {
     currentSpook -= scareAmount;
     currentVisitorState = VisitorState.GETTING_SPOOKED;
 }
        protected void OnSpawnVisitorFromCar(Message msg)
        {
            var           _msg   = msg as SpawnVisitorFromCar;
            EntityVisitor entity = null;

            VisitorState defaultState = VisitorState.GotoZooEntry;

            switch (_msg.stage)
            {
            case VisitorStage.GotoZoo:
                //defaultState = VisitorState.EnterZoo;
                defaultState = VisitorState.GotoZooEntry;
                break;

            case VisitorStage.GotoParking:
                defaultState = VisitorState.GotoParking;
                break;

            default:
                string e = string.Format("VisitorStage 异常{0}", _msg.stage);
                throw new System.Exception(e);
            }

            if (isRandomSpawn)
            {
                //entity = EntityManager.GetInstance().GetRandomEntity(
                //    ResType.Visitor, EntityFuncType.Visitor_From_Car) as EntityVisitor;
                entity = EntityManager.GetInstance().GetRandomEntity(
                    ResType.Visitor, _msg.funcType) as EntityVisitor;
            }
            else
            {
                //entity = EntityManager.GetInstance().GenEntityGameObject(
                //    101, EntityFuncType.Visitor_From_Car) as EntityVisitor;
                entity = EntityManager.GetInstance().GenEntityGameObject(
                    101, _msg.funcType) as EntityVisitor;
            }

            DebugFile.GetInstance().MarkGameObject(entity.mainGameObject, "visitor_{0}", entity.entityID);

            EntityManager.GetInstance().AddToEntityMovables(entity);

            //LogWarp.LogError("测试:  生成游客  name=  "+ entity.mainGameObject.name);


            if (entity.anim == null)
            {
                entity.anim = new SimpleAnimation();
            }
            //entity.anim.Init(entity.mainGameObject);
            entity.InitAnim();

            entity.moveSpeed = Config.globalConfig.getInstace().ZooVisitorSpeed;
            if (entity.followPath == null)
            {
                entity.followPath = new FollowPath();
            }

            if (entity.fsmMachine == null)
            {
                entity.fsmMachine = new FSMMachineVisitor(entity);
                //entity.fsmMachine.AddState(new StateVisitorEnterZoo((int)VisitorState.EnterZoo,
                //    entity.fsmMachine));
                entity.fsmMachine.AddState(new StateVisitorGotoZooEntry((int)VisitorState.GotoZooEntry,
                                                                        entity.fsmMachine));
                entity.fsmMachine.AddState(new StateVisitorLeaveZooEntryQueueFull((int)VisitorState.LeaveZooEntryQueueFull,
                                                                                  entity.fsmMachine));
                entity.fsmMachine.AddState(new StateVisitorEntryQueue((int)VisitorState.EntryQueue,
                                                                      entity.fsmMachine));
                entity.fsmMachine.AddState(new StateVisitorStayFirstPosInEntryQueue((int)VisitorState.StayFirstPosInEntryQueue,
                                                                                    entity.fsmMachine));
                entity.fsmMachine.AddState(new StateVisitorChoseLittleZoo((int)VisitorState.ChoseLittleZoo,
                                                                          entity.fsmMachine));
                entity.fsmMachine.AddState(new StateVisitorEnterLittleZooApply((int)VisitorState.EnterLittleZooApply,
                                                                               entity.fsmMachine));
                //entity.fsmMachine.AddState(new StateVisitorStayWaitSeat((int)VisitorState.StayWaitSeat,
                //    entity.fsmMachine));
                entity.fsmMachine.AddState(new StateVisitorStayVisitSeat((int)VisitorState.StayVisitSeat,
                                                                         entity.fsmMachine));
                entity.fsmMachine.AddState(new StateVisitorLeaveNonLittleZoo((int)VisitorState.LeaveNonLittleZoo,
                                                                             entity.fsmMachine));
                //entity.fsmMachine.AddState(new StateVisitorCrossGroupPath((int)VisitorState.CrossGroupPath,
                //    entity.fsmMachine));
                entity.fsmMachine.AddState(new StateVisitorLeaveFromZooEntry((int)VisitorState.LeaveFromZooEntry,
                                                                             entity.fsmMachine));
                //entity.fsmMachine.AddState(new StateVisitorGotoStartOfExitGateEntryPath((int)VisitorState.GotoStartOfExitGateEntryPath,
                //    entity.fsmMachine));
                //entity.fsmMachine.AddState(new StateVisitorGotoExitGateEntryQueue((int)VisitorState.GotoExitGateEntryQueue,
                //    entity.fsmMachine));
                entity.fsmMachine.AddState(new StateVisitorGotoParking((int)VisitorState.GotoParking,
                                                                       entity.fsmMachine));
                entity.fsmMachine.AddState(new StateVisitorGotoGroundParking((int)VisitorState.GotoGroundParking,
                                                                             entity.fsmMachine));


                entity.fsmMachine.SetDefaultState((int)defaultState);
            }
            else
            {
                //LogWarp.LogError("pool游客");
                //entity.fsmMachine.GotoState((int)VisitorState.GotoZooEntry);

                entity.fsmMachine.GotoState((int)defaultState);
            }
            entity.Active();
            //entity.fsmMachine.Run();
            entity.PlayActionAnim(Config.globalConfig.getInstace().VisitorWalk);

            TracedCamera(entity, isTracedVisitor);
        }