コード例 #1
0
        public static SitCommand Sit(
            Commander Owner,
            SeatControl Target,
            int?Priority = null,
            float?Delay  = null
            )
        {
            if (Owner == null)
            {
                throw new System.Exception("Commander.Walk: Owner does not exist!");
            }
            if (Target == null)
            {
                throw new System.Exception("Commander.Walk: Destination does not exist!");
            }

            SitCommand c = new SitCommand()
            {
                owner    = Owner,
                state    = CommandState.New,
                priority = Priority == null ? DefaultCommandPriority : Priority.Value,
                delay    = Delay == null ? 0 : Delay.Value,
                target   = Target
            };

            return(c);
        }
コード例 #2
0
        protected virtual IEnumerator CommitSit(SitCommand cmd)
        {
            // already sitting somewhere
            if (SeatState != null)
            {
                // if sitting on the place where supposed to sit, do nothing
                if (SeatState == cmd.target)
                {
                    Log.Write(name + " received Sit at " + cmd.target.gameObject.GetObjectIdentifier().identifyAs + " but already sitting there.", LogRecordType.Commander);
                    yield break;
                }
                // otherwise standup and go to the seat
                else
                {
                    yield return(StartCoroutine(StandUp()));
                }
            }

            // check distance, if too far, walk there
            float distance = (transform.position - cmd.target.ConstraintStandUp.transform.position).magnitude;

            if (distance > Command.DefaultStoppingDistance)
            {
                Log.Write(name + " received Sit at " + cmd.target.gameObject.GetObjectIdentifier().identifyAs + " and is too far (" + distance.ToString("0.00") + "). Going there.", LogRecordType.Commander);
                yield return(StartCoroutine(Walk(cmd, cmd.target.ConstraintStandUp, WalkCommand.WalkCommandEndingStyle.None, false, 0.1f, false)));
            }

            yield return(StartCoroutine(Sit(cmd.target)));
        }
コード例 #3
0
        private static SitCommand SitFromString(Commander Owner, int Priority, CommandState State, float Delay, ushort SyncId, ushort Successor, ushort Predecesssor, List <ushort> SyncsWithList, string[] parsed)
        {
            SeatControl Destination = null;

            foreach (string s in parsed)
            {
                string attribute;
                string value;
                GetAttributeAndValue(s, out attribute, out value);
                switch (attribute)
                {
                case "tgt": Destination = ObjectIdentifier.Find(value).seatControl; Debug.Log(Destination.name); break;
                }
            }

            SitCommand sc = new SitCommand()
            {
                owner       = Owner,
                state       = State,
                syncId      = SyncId,
                priority    = Priority,
                delay       = Delay,
                successor   = Successor,
                predecessor = Predecesssor,
                syncsWith   = SyncsWithList,
                target      = Destination
            };

            return(sc);
        }
コード例 #4
0
 protected override IEnumerator Commit(Command command)
 {
     if (command is WalkCommand)
     {
         yield return(StartCoroutine(CommitWalk((WalkCommand)command)));
     }
     else if (command is SitCommand)
     {
         SitCommand sitCommand = (SitCommand)command;
         yield return(StartCoroutine(CommitSit(sitCommand)));
     }
     else if (command is StandUpCommand)
     {
         yield return(StartCoroutine(StandUp()));
     }
     else
     {
         Log.Write("Command is not supported by AvatarCommander! " + command);
     }
 }