示例#1
0
        public override System.Object Create(params object[] arguments)
        {
            GameObject sheep = new GameObject("Sheep");

            GameObject sheepVisuals;

            if (m_Settings != null)
            {
                sheepVisuals = GameObject.Instantiate <GameObject> (m_Settings.FactorySettings.SheepVisualPrefab);
            }
            else
            {
                sheepVisuals = GameObject.CreatePrimitive(PrimitiveType.Cube);
            }

            sheepVisuals.transform.SetParent(sheep.transform);
            sheepVisuals.transform.localPosition = Vector3.zero;
            sheepVisuals.transform.localRotation = Quaternion.Euler(0, 90, 0);

            for (int i = 0; i < arguments.Length; i++)
            {
                if (arguments [i] is Transform)
                {
                    Transform setTo = arguments [i] as Transform;
                    sheep.transform.position   = setTo.position;
                    sheep.transform.rotation   = setTo.rotation;
                    sheep.transform.localScale = setTo.localScale;
                }
            }

            SheepFacade facade = sheep.AddComponent <SheepFacade> ();

            facade.Construct(m_Settings);

            GroundBasedMovement gbm = sheep.AddComponent <GroundBasedMovement> ();

            gbm.Construct();
            FaceTowardsTarget ftt = sheep.AddComponent <FaceTowardsTarget> ();

            ftt.Construct();

            return(facade);
        }
示例#2
0
        public SheepIsAnxious(
            IFacadeBase facade,
            SheepIsAnxious.Settings settings
            ) : base(
                facade
                )
        {
            m_Settings      = settings;
            m_Dependencies  = new SheepIsAnxious.Dependencies();
            m_CurrentFields = new SheepIsAnxious.CurrentFields();

            SheepFacade sheepFac = (facade as SheepFacade);

            if (sheepFac)
            {
                m_Dependencies.Controller = sheepFac.Controller;
                m_Dependencies.Model      = sheepFac.Model;
                m_Dependencies.Movable    = (sheepFac.Model.Targets as ITargetsMovable);
            }
        }
示例#3
0
        public SheepIsCalm(
            IFacadeBase facade,
            SheepIsCalm.Settings settings
            ) : base(
                facade
                )
        {
            m_Settings      = settings;
            m_Dependencies  = new SheepIsCalm.Dependencies();
            m_CurrentFields = new SheepIsCalm.CurrentFields();

            SheepFacade sheepFac = (facade as SheepFacade);

            if (sheepFac)
            {
                m_Dependencies.Controller = sheepFac.Controller;
                m_Dependencies.Model      = sheepFac.Model;
                ITargetsMovable movable = m_Dependencies.Model.Targets as ITargetsMovable;
                if (movable != null)
                {
                    movable.MovementTarget = m_Dependencies.Model.Position + Vector3.forward;
                }
            }
        }