protected override AgentState CreateState(string currentTimePropertySet)
        {
            string[] propertyStrings = currentTimePropertySet.Split(tabulationDelimiter);

            Vector3 position  = new Vector3();
            Vector3 direction = new Vector3();
            Color   color     = new Color();

            if (propertyStrings.Length > 2)
            {
                color = this.GetColorFromInput(propertyStrings[2].Split(valueDelimiter));
            }

            if (propertyStrings.Length > 1)
            {
                direction = this.GetDirectionFromInput(propertyStrings[1].Split(valueDelimiter));
            }

            if (propertyStrings.Length > 0)
            {
                position = this.GetPositionFromInput(propertyStrings[0].Split(valueDelimiter));
            }

            DemoAgentState newState = new DemoAgentState(position, direction, color);

            return(newState);
        }
Пример #2
0
        protected override void UpdateProperties()
        {
            DemoAgentState currentAgentState = (DemoAgentState)this.currentAgentState;

            //Updating direction
            if (currentAgentState.direction != Vector3.zero && !TransitionDone)
            {
                transform.forward = currentAgentState.direction;
            }
            else if (!TransitionDone)
            {
                transform.forward = (currentAgentState.position - transform.position).normalized;
            }
            //Updating color
            this.GetComponent <MeshRenderer>().material.color = currentAgentState.color;
            Renderer[] renderInChildren = this.GetComponentsInChildren <MeshRenderer>();
            foreach (Renderer renderer in renderInChildren)
            {
                renderer.material.color = currentAgentState.color;
            }
            return;
        }