// Start is called before the first frame update
    void Start()
    {
        NowButton          = 0;
        button             = new Button[2];
        button[0]          = GameObject.Find("Canvas/NextStage").GetComponent <Button>();
        button[1]          = GameObject.Find("Canvas/StageSelect").GetComponent <Button>();
        buttonanimation    = new Animator[2];
        buttonanimation[0] = button[0].GetComponent <Animator>();
        buttonanimation[1] = button[1].GetComponent <Animator>();

        //canvas = GameObject.GetComponentInChildren<GameObject>();
        canvas.SetActive(false);
        scene        = GameObject.Find("SceneManager").GetComponent <SceneComponent>();
        PauseManager = GameObject.Find("PauseManager").GetComponent <PauseManager>();
    }
    protected internal override void OnEnter(IFsm <IProcedureManager> procedureOwner)
    {
        base.OnEnter(procedureOwner);

        SceneComponent scene
            = UnityGameFramework.Runtime.GameEntry.GetComponent <SceneComponent>();

        // 切换场景

        scene.LoadScene("Assets/Demo/Event/Demo4_Menu.unity", this);

        // 切换流程

        ChangeState <Demo4_ProcedureMenu>(procedureOwner);
    }
예제 #3
0
    protected internal override void OnEnter(ProcedureOwner procedureOwner)
    {
        base.OnEnter(procedureOwner);

        Log.Debug("初始!!");

        SceneComponent scene
            = UnityGameFramework.Runtime.GameEntry.GetComponent <SceneComponent>();

        // 切换场景
        scene.LoadScene("Assets/Demo/Scene/sceneMenu.unity", this);

        // 切换流程
        ChangeState <Scene_Menu>(procedureOwner);
    }
예제 #4
0
    protected override void OnEnter(ProcedureOwner procedureOwner)
    {
        base.OnEnter(procedureOwner);
        owner = procedureOwner;
        Debug.Log("进入菜单流程,可以在这里加载菜单UI。");

        // 加载框架Event组件
        // 加载框架UI组件

        scene = UnityGameFramework.Runtime.GameEntry.GetComponent <SceneComponent>();
        // 订阅UI加载成功事件
        GameEntry.Event.Subscribe(OpenUIFormSuccessEventArgs.EventId, OnOpenUIFormSuccess);
        GameEntry.Event.Subscribe(GameBeganEventArgs.EventId, BeginGame);
        // 加载UI
        MenuUI_ID = GameEntry.UI.OpenUIForm("Assets/Learning/UI_Menu.prefab", "DefaultGroup", this);
    }
    public void EnterGame()
    {
        // 获取框架场景组件
        SceneComponent Scene
            = UnityGameFramework.Runtime.GameEntry.GetComponent <SceneComponent>();

        // 卸载所有场景
        string[] loadedSceneAssetNames = Scene.GetLoadedSceneAssetNames();
        for (int i = 0; i < loadedSceneAssetNames.Length; i++)
        {
            Scene.UnloadScene(loadedSceneAssetNames[i]);
        }

        // 加载游戏场景
        Scene.LoadScene("Assets/Demo2/Demo2_Game.unity", this);
    }
예제 #6
0
        protected override void OnLeave(ProcedureOwner procedureOwner, bool isShutdown)
        {
            base.OnLeave(procedureOwner, isShutdown);

            UIComponent UI = UnityGameFramework.Runtime.GameEntry.GetComponent <UIComponent>();

            UI.CloseUIForm(mUIId);

            //取消订阅成功事件
            Event.Unsubscribe(OpenUIFormSuccessEventArgs.EventId, OnOpenUIFormSuccess);
            Event.Unsubscribe(OpenUIFormFailureEventArgs.EventId, OnOpenUIFormFailure);

            //卸载场景
            SceneComponent sceneComp = UnityGameFramework.Runtime.GameEntry.GetComponent <SceneComponent>();

            sceneComp.UnloadScene(mSceneName);
        }
예제 #7
0
    // Start is called before the first frame update
    void Start()
    {
        Scene = GameObject.Find("SceneManager").GetComponent <SceneComponent>();

        ani       = new Animator[3];
        trans     = new int[3];
        Ani       = new bool[3];
        Direction = new bool[3];
        img       = new Button[3];
        HashName  = new int[3];

        ani[0] = GameObject.Find("1~10").GetComponent <Animator>();
        ani[1] = GameObject.Find("11~20").GetComponent <Animator>();
        ani[2] = GameObject.Find("21~30").GetComponent <Animator>();
        img[0] = GameObject.Find("1~10").GetComponent <Button>();
        img[1] = GameObject.Find("11~20").GetComponent <Button>();
        img[2] = GameObject.Find("21~30").GetComponent <Button>();

        for (int i = 0; i < 3; i++)
        {
            trans[i]       = i + 1;
            Ani[i]         = ani[i].GetBool("Ani");
            Direction[i]   = ani[i].GetBool("Direction");
            ani[i].enabled = true;
            ani[i].SetInteger("trans", trans[i]);
        }

        //if (gameObject.name == "1~10")
        //{
        //    trans = 1;
        //    img = GameObject.Find("1~10").GetComponent<Image>();
        //}
        //if (gameObject.name == "11~20")
        //{
        //    trans = 2;
        //    img = GameObject.Find("11~20").GetComponent<Image>();
        //}
        //if (gameObject.name == "21~30")
        //{
        //    trans = 3;
        //    img = GameObject.Find("21~30").GetComponent<Image>();
        //}

        BackButton = GameObject.Find("戻る").GetComponent <Button>();
    }
    protected internal override void OnUpdate(IFsm <IProcedureManager> procedureOwner, float elapseSeconds, float realElapseSeconds)
    {
        base.OnUpdate(procedureOwner, elapseSeconds, realElapseSeconds);

        if (!m_ResourceInitComplete)
        {
            return;
        }

        SceneComponent Scene
            = UnityGameFramework.Runtime.GameEntry.GetComponent <SceneComponent>();

        // 切换场景
        Scene.LoadScene("Assets/Demo/AssetBundle/Demo9_menu.unity", this);

        // 切换流程
        ChangeState <Demo9_ProcedureMenu>(procedureOwner);
    }
 public RheinWerkGameWindows()
 {
     graphics = new GraphicsDeviceManager(this);
     Content.RootDirectory = "Content";
     Input             = new InputComponent(this);
     Input.UpdateOrder = 0;
     Components.Add(Input);
     Simulation             = new SimulationComponent(this);
     Simulation.UpdateOrder = 1;
     Components.Add(Simulation);
     Scene             = new SceneComponent(this);
     Scene.UpdateOrder = 2;
     Components.Add(Scene);
     Hud             = new HudComponent(this);
     Hud.UpdateOrder = 3;
     Hud.DrawOrder   = 1;
     Components.Add(Hud);
 }
예제 #10
0
 public void InitComponent(Transform componentRoot)
 {
     this.ComponentRoot    = componentRoot;
     DataNodeComponent     = FindAndRegisterComponent <DataNodeComponent>();
     DataTableComponent    = FindAndRegisterComponent <DataTableComponent>();
     DownloadComponent     = FindAndRegisterComponent <DownloadComponent>();
     FsmComponent          = FindAndRegisterComponent <FSMComponent>();
     ResourceComponent     = FindAndRegisterComponent <ResourceComponent>();
     SettingComponent      = FindAndRegisterComponent <SettingComponent>();
     SoundComponent        = FindAndRegisterComponent <SoundComponent>();
     TimerComponent        = FindAndRegisterComponent <TimerComponent>();
     WebComponent          = FindAndRegisterComponent <WebComponent>();
     UpdateComponent       = FindAndRegisterComponent <UpdateComponent>();
     LocalizationComponent = FindAndRegisterComponent <LocalizationComponent>();
     VideoComponent        = FindAndRegisterComponent <VideoComponent>();
     InputComponent        = FindAndRegisterComponent <InputComponent>();
     SceneComponent        = FindAndRegisterComponent <SceneComponent>();
 }
예제 #11
0
        /// <summary>
        /// 游戏框架组件初始化。
        /// </summary>
        protected override void Awake()
        {
            base.Awake();

            m_SceneMethods = CentorPivot.This.GetComponent <SceneComponent>();

            if (m_SceneMethods == null)
            {
                Log.Fatal("Scene manager is invalid.");
                return;
            }

            m_SceneMethods.LoadSceneSuccess += OnLoadSceneSuccess;
            m_SceneMethods.LoadSceneFailure += OnLoadSceneFailure;

            if (m_EnableLoadSceneUpdateEvent)
            {
                m_SceneMethods.LoadSceneUpdate += OnLoadSceneUpdate;
            }

            if (m_EnableLoadSceneDependencyAssetEvent)
            {
                m_SceneMethods.LoadSceneDependencyAsset += OnLoadSceneDependencyAsset;
            }

            m_SceneMethods.UnloadSceneSuccess += OnUnloadSceneSuccess;
            m_SceneMethods.UnloadSceneFailure += OnUnloadSceneFailure;

            m_GameFrameworkScene = UnityEngine.SceneManagement.SceneManager.GetSceneAt(ApplicationHelper.SceneId);
            if (!m_GameFrameworkScene.IsValid())
            {
                Log.Fatal("Game Framework scene is invalid.");
                return;
            }

            if (EventComponent.This == null)
            {
                Log.Fatal("Event component is invalid.");
                return;
            }

            m_SceneMethods.SetResourceManager(CentorPivot.This.GetComponent <ResourceComponent>());
            //Instantiation = this;
        }
 IEnumerator SwitchSene(SceneComponent sceneExit, SceneComponent sceneEnter)
 {
     if (sceneExit != null)
     {
         bool closed = false;
         UnityEngine.Events.UnityAction wait = () => {
             closed = true;
         };
         transitionScreen.OnTransitionComplete.AddListener(wait);
         //シーンの終了処理を行う
         sceneExit.ExitScne();
         //画面をフェードアウトさせる
         transitionScreen.Close(sceneExit.FadeoutColor, sceneExit.FadeoutDuration);
         //フェード完了までまつ
         while (!closed)
         {
             yield return(null);
         }
         transitionScreen.OnTransitionComplete.RemoveListener(wait);
         //フェード完了後処理をする
         sceneExit.OnCompleteExit();
         sceneExit.gameObject.SetActive(false);
     }
     if (sceneEnter != null)
     {
         bool closed = true;
         UnityEngine.Events.UnityAction wait = () => {
             closed = false;
         };
         sceneEnter.gameObject.SetActive(true);
         transitionScreen.OnTransitionComplete.AddListener(wait);
         //シーンの開始処理をする
         sceneEnter.EntertScene();
         //画面をフェードインさせる
         transitionScreen.Open(sceneEnter.FadeinColor, sceneEnter.FadeinDuration);
         //フェードインをまつ
         while (closed)
         {
             yield return(null);
         }
         transitionScreen.OnTransitionComplete.RemoveListener(wait);
     }
 }
예제 #13
0
        private List <RaycastHitResult> RaycastAllInternal(Ray ray)
        {
            if (Map == null)
            {
                throw new InvalidOperationException("Cannot raycast against an unloaded map!");
            }

            List <RaycastHitResult> returnResults = new List <RaycastHitResult>();

            foreach (Room room in Map.Rooms)
            {
                foreach (var entity in room.Entities)
                {
                    if (!Map.LayerIsVisible(entity.Layer))
                    {
                        continue;
                    }

                    SceneComponent sceneEntity = entity as SceneComponent;
                    if (sceneEntity == null)
                    {
                        continue;
                    }


                    Vector3 aabbMin, aabbMax;
                    sceneEntity.GetAABB(out aabbMin, out aabbMax);

                    float intersectionDist;
                    if (RayIntersectsAABB(ray, aabbMin, aabbMax, out intersectionDist))
                    {
                        RaycastHitResult result = new RaycastHitResult();
                        result.Distance = intersectionDist;
                        result.Entity   = entity;
                        returnResults.Add(result);
                    }
                }
            }

            // Sort the results - nearest to furthest.
            returnResults = returnResults.OrderBy(x => x.Distance).ToList();
            return(returnResults);
        }
예제 #14
0
        private void HashCodesTest()
        {
            Debug.Log(LogLevel.Display, "Starting " + MethodBase.GetCurrentMethod().Name + "...");

            Actor          actorLeft           = new Actor();
            Actor          actorRight          = new Actor();
            SceneComponent sceneComponentLeft  = new SceneComponent(actorLeft);
            SceneComponent sceneComponentRight = new SceneComponent(actorRight);

            if (sceneComponentLeft.GetHashCode() == sceneComponentRight.GetHashCode() || sceneComponentLeft.GetHashCode() != sceneComponentLeft.GetHashCode())
            {
                Debug.Log(LogLevel.Error, "Scene components hash codes check failed!");

                return;
            }

            sceneComponentLeft.Destroy();

            if (sceneComponentRight.GetHashCode() == sceneComponentLeft.GetHashCode())
            {
                Debug.Log(LogLevel.Error, "Scene components hash codes check after destruction failed!");

                return;
            }

            if (actorLeft.GetHashCode() == actorRight.GetHashCode() || actorLeft.GetHashCode() != actorLeft.GetHashCode())
            {
                Debug.Log(LogLevel.Error, "Actors hash codes check failed!");

                return;
            }

            actorLeft.Destroy();

            if (actorRight.GetHashCode() == actorLeft.GetHashCode())
            {
                Debug.Log(LogLevel.Error, "Actors hash codes check after destruction failed!");

                return;
            }

            Debug.Log(LogLevel.Display, "Test passed successfully");
        }
예제 #15
0
    protected override void OnUpdate(ProcedureOwner procedureOwner, float elapseSeconds, float realElapseSeconds)
    {
        base.OnUpdate(procedureOwner, elapseSeconds, realElapseSeconds);

        if (m_StartGame)
        {
            SceneComponent scene = GameEntry.GetComponent <SceneComponent>();
            //获取所有已经加载的场景名
            string[] loadedSceneNames = scene.GetLoadedSceneAssetNames();
            //遍历并删除场景
            foreach (string sceneName in loadedSceneNames)
            {
                scene.UnloadScene(sceneName);
            }
            //加载新场景
            scene.LoadScene("Assets/Demo3_UI/Demo3_Game.unity", this);
            //切换流程
            ChangeState <Demo3_ProcedureGame>(procedureOwner);
        }
    }
예제 #16
0
        public void Render(Matrix4 viewMatrix, Matrix4 projectionMatrix)
        {
            UpdateWorldMatrix();
            shader.startProgram();
            texture.BindTexture(OpenTK.Graphics.OpenGL.TextureUnit.Texture0);
            shader.SetDiffuseTexture(0);
            shader.SetTransformatrionMatrices(WorldMatrix, viewMatrix, projectionMatrix);
            shader.SetOpacity(1);
            VAOManager.renderBuffers(rawModel.Buffer, OpenTK.Graphics.OpenGL.PrimitiveType.Triangles);
            shader.stopProgram();

            foreach (var item in ChildrenComponents)
            {
                SceneComponent comp = item as SceneComponent;
                if (comp != null)
                {
                    comp.RenderBound(ref projectionMatrix, ref viewMatrix, OpenTK.Graphics.Color4.Red);
                }
            }
        }
예제 #17
0
        public AdventureGame()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            World = new GameWorld(this);

            Input             = new InputComponent(this);
            Input.UpdateOrder = 0;
            Components.Add(Input);

            Simulation             = new SimulationComponent(this);
            Simulation.UpdateOrder = 1;
            Components.Add(Simulation);

            Scene             = new SceneComponent(this);
            Scene.UpdateOrder = 2;
            Scene.DrawOrder   = 0;
            Components.Add(Scene);
        }
예제 #18
0
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            // Objektinstanzen erzeugen
            Input      = new InputComponent(this);
            Scene      = new SceneComponent(this);
            Simulation = new SimulationComponent(this);

            // Komponenten hinzufügen
            Components.Add(Input);
            Components.Add(Scene);
            Components.Add(Simulation);

            // Update Order bestimmt in welcher Reihenfolge die Komponenten gemalt werden
            Input.UpdateOrder      = 0;
            Simulation.UpdateOrder = 1;
            Scene.UpdateOrder      = 2;
        }
예제 #19
0
    public Transform CreateSceneFolder(SceneDescriptor sceneDescriptor)
    {
        GameObject scene = Instantiate(_buildParams.ScenePrefab);

        scene.name = sceneDescriptor.sceneName;

        SceneComponent sceneComponent = scene.GetComponent <SceneComponent>();

        if (sceneComponent != null)
        {
            sceneComponent.SceneSize = sceneDescriptor.sceneSize;
        }
        else
        {
            sceneComponent           = scene.AddComponent <SceneComponent>();
            sceneComponent.SceneSize = sceneDescriptor.sceneSize;
        }

        return(scene.transform);
    }
예제 #20
0
        /// <summary>
        /// The add scene component.
        /// </summary>
        /// <param name="sceneId">
        /// The scene id.
        /// </param>
        /// <param name="sc">
        /// The sc.
        /// </param>
        public static void AddSceneComponent(int sceneId, ref SceneComponent sc)
        {
            // SetUpLists(sceneId);
            List <SceneComponent> updateableComponents;

            if (sceneComponents.TryGetValue(sceneId, out updateableComponents))
            {
                int index = updateableComponents.BinarySearch(sc, UpdateableOrderComparer.Default);
                if (index < 0)
                {
                    index = ~index;
                    while ((index < updateableComponents.Count) &&
                           (updateableComponents[index].UpdateOrder == sc.UpdateOrder))
                    {
                        index++;
                    }

                    updateableComponents.Insert(index, sc);
                }
            }
        }
예제 #21
0
        /// <summary>
        /// The update order changed.
        /// </summary>
        /// <param name="sceneId">
        /// The scene id.
        /// </param>
        /// <param name="sc">
        /// The sc.
        /// </param>
        public static void UpdateOrderChanged(int sceneId, SceneComponent sc)
        {
            List <SceneComponent> updateableComponents;

            if (sceneComponents.TryGetValue(sceneId, out updateableComponents))
            {
                updateableComponents.Remove(sc);
                int index = updateableComponents.BinarySearch(sc, UpdateableOrderComparer.Default);
                if (index < 0)
                {
                    index = ~index;
                    while ((index < updateableComponents.Count) &&
                           (updateableComponents[index].UpdateOrder == sc.UpdateOrder))
                    {
                        index++;
                    }

                    updateableComponents.Insert(index, sc);
                }
            }
        }
예제 #22
0
        private void ComponentBlueprintClassesMatchingTest()
        {
            Debug.Log(LogLevel.Display, "Starting " + MethodBase.GetCurrentMethod().Name + "...");

            try {
                Blueprint blueprintComponent = Blueprint.Load("/Game/Tests/BlueprintStaticMeshComponent");
                Actor     actor = new Actor();

                Debug.Log(LogLevel.Display, "Triggering invalid action after the blueprint loading");

                SceneComponent sceneComponent = new SceneComponent(actor, blueprint: blueprintComponent);
            }

            catch (Exception exception) {
                Debug.Log(LogLevel.Display, "The exception has successfully reached: " + exception.Message);

                return;
            }

            Debug.Log(LogLevel.Error, "Test failed!");
        }
        private string GetSceneNameString(string[] sceneAssetNames)
        {
            if (sceneAssetNames == null || sceneAssetNames.Length <= 0)
            {
                return("<Empty>");
            }

            string sceneNameString = string.Empty;

            foreach (string sceneAssetName in sceneAssetNames)
            {
                if (!string.IsNullOrEmpty(sceneNameString))
                {
                    sceneNameString += ", ";
                }

                sceneNameString += SceneComponent.GetSceneName(sceneAssetName);
            }

            return(sceneNameString);
        }
예제 #24
0
        private void ComponentsMatchingTest()
        {
            Debug.Log(LogLevel.Display, "Starting " + MethodBase.GetCurrentMethod().Name + "...");

            Actor actor = new Actor();
            StaticMeshComponent          staticMeshComponent          = new StaticMeshComponent(actor, setAsRoot: true);
            SceneComponent               sceneComponent               = actor.GetRootComponent <SceneComponent>();
            InstancedStaticMeshComponent instancedStaticMeshComponent = actor.GetRootComponent <InstancedStaticMeshComponent>();

            if (sceneComponent == null)
            {
                Debug.Log(LogLevel.Error, "Component obtainment with inherited type matching to the root component failed!");

                return;
            }

            if (instancedStaticMeshComponent != null)
            {
                Debug.Log(LogLevel.Error, "Component obtainment with type matching to the root component failed!");

                return;
            }

            if (actor.GetComponent <StaticMeshComponent>() == null)
            {
                Debug.Log(LogLevel.Error, "Component type matching failed!");

                return;
            }

            if (actor.GetRootComponent <StaticMeshComponent>() == null)
            {
                Debug.Log(LogLevel.Error, "Component type matching to the root component failed!");

                return;
            }

            Debug.Log(LogLevel.Display, "Test passed successfully");
        }
예제 #25
0
        private static void NamingTest()
        {
            Debug.Log(LogLevel.Display, "Starting " + MethodBase.GetCurrentMethod().Name + "...");

            const string actorName     = "TestActorName";
            const string componentName = "TestComponentName";
            const string renamedSuffix = "Renamed";

            Actor          actor          = new Actor(actorName);
            SceneComponent sceneComponent = new SceneComponent(actor, componentName);

            if (actor.Name != actorName || sceneComponent.Name != componentName)
            {
                Debug.Log(LogLevel.Error, "Names check failed!");

                return;
            }

            Actor namedActor = World.GetActor <Actor>(actorName);

            if (!actor.Equals(namedActor))
            {
                Debug.Log(LogLevel.Error, "Actor from world with a name check after removing failed!");

                return;
            }

            actor.Rename(actorName + renamedSuffix);
            sceneComponent.Rename(componentName + renamedSuffix);

            if (actor.Name != actorName + renamedSuffix || sceneComponent.Name != componentName + renamedSuffix)
            {
                Debug.Log(LogLevel.Error, "Renaming check failed!");

                return;
            }

            Debug.Log(LogLevel.Display, "Test passed successfully");
        }
예제 #26
0
    // Start is called before the first frame update
    void Start()
    {
        SceneManager    = GameObject.Find("SceneManager");
        scene           = SceneManager.GetComponent <SceneComponent>();
        scene.TitleFlag = false;
        AnyFlag         = false;
        AxisTrg         = false;
        starttrg        = false;
        NowButton       = 1;

        Titlebutton    = new Button[3];
        Titlebutton[0] = GameObject.Find("Canvas/Any").GetComponent <Button>();
        Titlebutton[1] = GameObject.Find("Canvas/Start").GetComponent <Button>();
        Titlebutton[2] = GameObject.Find("Canvas/GameEnd").GetComponent <Button>();

        Titlebutton[0].interactable = true;
        Titlebutton[1].interactable = false;
        Titlebutton[2].interactable = false;

        Alphabutton    = new AlphaChange[3];
        Alphabutton[0] = Titlebutton[0].gameObject.GetComponent <AlphaChange>();
        Alphabutton[1] = Titlebutton[1].gameObject.GetComponent <AlphaChange>();
        Alphabutton[2] = Titlebutton[2].gameObject.GetComponent <AlphaChange>();

        for (int i = 0; i < 3; i++)
        {
            if (i == 0)
            {
                Titlebutton[i].interactable = true;
                Alphabutton[i].AlphaStart   = true;
            }
            else
            {
                Titlebutton[i].interactable = false;
                Alphabutton[i].AlphaStart   = false;
            }
        }
    }
예제 #27
0
        public static void OnBeginPlay()
        {
            Debug.Log(LogLevel.Display, "Hello, Unreal Engine!");
            Debug.AddOnScreenMessage(-1, 3.0f, Color.LightGreen, MethodBase.GetCurrentMethod().DeclaringType + " system started!");

            World.GetFirstPlayerController().SetViewTarget(World.GetActor <Camera>("MainCamera"));

            instancedStaticMeshComponent.SetStaticMesh(StaticMesh.Cube);
            instancedStaticMeshComponent.SetMaterial(0, material);
            instancedStaticMeshComponent.CreateAndSetMaterialInstanceDynamic(0).SetVectorParameterValue("Color", LinearColor.White);

            for (int i = 0; i < maxCubes; i++)
            {
                sceneComponent[i] = new SceneComponent(actor);
                sceneComponent[i].SetRelativeLocation(new Vector3(50.0f * i, 100.0f * i, 150.0f * i));
                sceneComponent[i].SetRelativeRotation(Quaternion.CreateFromYawPitchRoll(5.0f * i, 0.0f, 0.0f));
                sceneComponent[i].AddLocalOffset(new Vector3(15.0f * i, 20.0f * i, 25.0f * i));
                sceneComponent[i].GetTransform(ref transform);
                instancedStaticMeshComponent.AddInstance(transform);
            }

            Debug.AddOnScreenMessage(-1, 3.0f, Color.LightGreen, "Instances are created! Number of instances: " + instancedStaticMeshComponent.InstanceCount);
        }
예제 #28
0
        private void ComponentMemoryManagementTest()
        {
            Debug.Log(LogLevel.Display, "Starting " + MethodBase.GetCurrentMethod().Name + "...");

            try {
                Actor          actor          = new Actor();
                SceneComponent sceneComponent = new SceneComponent(actor, setAsRoot: true);

                sceneComponent.Destroy();

                Debug.Log(LogLevel.Display, "Triggering invalid action after the destruction");

                sceneComponent.AddLocalOffset(default(Vector3));
            }

            catch (Exception exception) {
                Debug.Log(LogLevel.Display, "The exception has successfully reached: " + exception.Message);

                return;
            }

            Debug.Log(LogLevel.Error, "Test failed!");
        }
예제 #29
0
        private static BoundBase UpdateCollisionBound(ref SceneComponent component, float[,] vertices)
        {
            BoundBase resultBound = null;

            AABB aabb = AABB.CreateFromMinMax(
                FindEdgeInMesh((lhv, rhv) => { return(Math.Min(lhv, rhv)); }, vertices),
                FindEdgeInMesh((lhv, rhv) => { return(Math.Max(lhv, rhv)); }, vertices),
                component);
            Matrix4    TransformMatrix = component.GetWorldMatrix();
            Quaternion rotation        = TransformMatrix.ExtractRotation();

            if (rotation.Xyz.LengthSquared > 0.01f)
            {
                resultBound = new OBB(aabb.GetLocalSpaceOrigin(), aabb.GetLocalSpaceExtent(), TransformMatrix, component);
            }
            else
            {
                aabb.ScalePlusTranslation = TransformMatrix;
                resultBound = aabb;
            }

            return(resultBound);
        }
예제 #30
0
        private static void ProcessTransform(SceneComponent forObject)
        {
            // Remove the Position field as the Actor has a Transform which gives it a position.
            if (forObject.Fields.HasProperty("Position"))
            {
                forObject.Transform.Position = forObject.Fields.GetProperty <Vector3>("Position");
                forObject.Fields.RemoveProperty("Position");
            }

            // Remove the Rotation field.
            if (forObject.Fields.HasProperty("Rotation"))
            {
                Quaternion rotation = forObject.Fields.GetProperty <Quaternion>("Rotation");
                forObject.Transform.Rotation = rotation;
                forObject.Fields.RemoveProperty("Rotation");
            }

            // Remove the Scale field.
            if (forObject.Fields.HasProperty("Scale"))
            {
                forObject.Transform.LocalScale = forObject.Fields.GetProperty <Vector3>("Scale");
                forObject.Fields.RemoveProperty("Scale");
            }
        }
예제 #31
0
 public MiniMap(IScreenManager screenManager, SceneComponent scene)
     : base(screenManager)
 {
     Scene = scene;
 }
예제 #32
0
파일: Scene.cs 프로젝트: Pctg-x8/Altseed
 /// <summary>
 /// 指定したコンポーネントをこのシーンに追加する。
 /// </summary>
 /// <param name="component">追加するコンポーネント</param>
 /// <param name="key">コンポーネントに関連付けるキー</param>
 public void AddComponent(SceneComponent component, string key)
 {
     componentManager_.Add(component, key);
 }