Esempio n. 1
0
 public void Destroy()
 {
     if (this.planetMaterial != null)
     {
         UnityUtils.DestroyMaterial(this.planetMaterial);
         this.planetMaterial = null;
     }
     if (this.PlanetGameObject != null)
     {
         UnityEngine.Object.Destroy(this.PlanetGameObject);
         this.PlanetGameObject = null;
     }
     if (this.EventEffect != null)
     {
         UnityEngine.Object.Destroy(this.EventEffect);
         this.EventEffect = null;
     }
     if (this.PlanetGlowEffect != null)
     {
         UnityEngine.Object.Destroy(this.PlanetGlowEffect);
         this.PlanetGlowEffect = null;
     }
     this.DestroyParticles();
     this.Handle           = AssetHandle.Invalid;
     this.PlanetGameObject = null;
     this.VO            = null;
     this.ObjectExtents = Vector3.zero;
 }
 private void Destroy()
 {
     this.events.UnregisterObserver(this, EventId.MapDataProcessingStart);
     this.events.UnregisterObserver(this, EventId.WorldLoadComplete);
     this.events.UnregisterObserver(this, EventId.WorldInTransitionComplete);
     this.events.UnregisterObserver(this, EventId.TroopNotPlacedInvalidArea);
     this.events.UnregisterObserver(this, EventId.UserLiftedBuilding);
     this.events.UnregisterObserver(this, EventId.EnterEditMode);
     this.events.UnregisterObserver(this, EventId.ExitEditMode);
     this.events.UnregisterObserver(this, EventId.ShieldBorderDestroyed);
     this.events.UnregisterObserver(this, EventId.MissionStarted);
     this.IgnoreBoardChanges();
     if (this.textureHandle != AssetHandle.Invalid)
     {
         Service.Get <AssetManager>().Unload(this.textureHandle);
         this.textureHandle = AssetHandle.Invalid;
     }
     this.texture = null;
     if (this.material != null)
     {
         UnityUtils.DestroyMaterial(this.material);
         this.material = null;
     }
     this.CleanUp();
 }
Esempio n. 3
0
        public override bool Inspect(Material mat)
        {
            var changed = pegi.toggleDefaultInspector();

            mat.edit(Softness, "Softness", 0, 1).nl(ref changed);

            mat.edit(Outline).nl(ref changed);

            if (mat.IsKeywordEnabled(RoundedGraphic.UNLINKED_VERTICES))
            {
                "UNLINKED VERTICES".nl();
            }

            var go = UnityUtils.GetFocusedGameObject();

            if (go)
            {
                var rndd = go.GetComponent <RoundedGraphic>();

                if (!rndd)
                {
                    "No RoundedGrahic.cs detected, shader needs custom data.".writeWarning();
                }
                else if (!rndd.enabled)
                {
                    "Controller is disabled".writeWarning();
                }
            }

            return(changed);
        }
Esempio n. 4
0
        protected bool Raycast(UserInputLayer layer, Vector3 screenPosition, ref GameObject gameObjectHit, ref Vector3 groundPosition)
        {
            bool flag = false;

            switch (layer)
            {
            case UserInputLayer.InternalLowest:
                flag = this.activeWorldCamera.GetGroundPosition(screenPosition, ref groundPosition);
                break;

            case UserInputLayer.World:
                flag = this.RaycastHelper(this.activeWorldCamera, screenPosition, ref gameObjectHit);
                flag = (this.activeWorldCamera.GetGroundPosition(screenPosition, ref groundPosition) | flag);
                break;

            case UserInputLayer.UX:
            {
                GameObject gameObject = gameObjectHit;
                flag = this.RaycastHelper(this.uxCamera, screenPosition, ref gameObject);
                if (flag && this.clickThrough.Contains(gameObject))
                {
                    return(false);
                }
                if (flag && UnityUtils.ShouldIgnoreUIGameObjectInRaycast(gameObject))
                {
                    return(false);
                }
                gameObjectHit = gameObject;
                break;
            }
            }
            return(flag);
        }
Esempio n. 5
0
        public bool TryGetByGuid <T>(ref T field) where T : UnityEngine.Object
        {
            var obj = UnityUtils.GuidToAsset <T>(_guid);

            field = null;

            if (!obj)
            {
                return(false);
            }

            field = obj;

            if (componentType.IsNullOrEmpty())
            {
                return(true);
            }

            var go = obj as GameObject;

            if (!go)
            {
                return(true);
            }

            var getScripts = go.GetComponent(componentType) as T;

            if (getScripts)
            {
                field = getScripts;
            }

            return(true);
        }
Esempio n. 6
0
    public void Initialize(GameObject go)
    {
        rightElbow = UnityUtils.FindTransform(go, "R_Elbow");
        leftElbow  = UnityUtils.FindTransform(go, "L_Elbow");
        rightArm   = UnityUtils.FindTransform(go, "R_Arm");
        leftArm    = UnityUtils.FindTransform(go, "L_Arm");
        rightKnee  = UnityUtils.FindTransform(go, "R_Knee");
        leftKnee   = UnityUtils.FindTransform(go, "L_Knee");
        rightHip   = UnityUtils.FindTransform(go, "R_Hip");
        leftHip    = UnityUtils.FindTransform(go, "L_Hip");
        spine      = UnityUtils.FindTransform(go, "Spine_1");
        root       = UnityUtils.FindTransform(go, "Root");

        initialRotations = new Quaternion[(int)NiteWrapper.SkeletonJoint.END];
        initialRotations[(int)NiteWrapper.SkeletonJoint.LEFT_ELBOW]     = leftElbow.rotation;
        initialRotations[(int)NiteWrapper.SkeletonJoint.RIGHT_ELBOW]    = rightElbow.rotation;
        initialRotations[(int)NiteWrapper.SkeletonJoint.LEFT_SHOULDER]  = leftArm.rotation;
        initialRotations[(int)NiteWrapper.SkeletonJoint.RIGHT_SHOULDER] = rightArm.rotation;
        initialRotations[(int)NiteWrapper.SkeletonJoint.RIGHT_KNEE]     = rightKnee.rotation;
        initialRotations[(int)NiteWrapper.SkeletonJoint.LEFT_KNEE]      = leftKnee.rotation;
        initialRotations[(int)NiteWrapper.SkeletonJoint.RIGHT_HIP]      = rightHip.rotation;
        initialRotations[(int)NiteWrapper.SkeletonJoint.LEFT_HIP]       = leftHip.rotation;
        initialRotations[(int)NiteWrapper.SkeletonJoint.TORSO_CENTER]   = spine.rotation;
        initialRoot = root.rotation;

        RotateToCalibrationPose();
    }
Esempio n. 7
0
        public void OnBeginDrag(PointerEventData eventData)
        {
            Canvas canvas = UnityUtils.FindInParent <Canvas>(gameObject);

            if (canvas != null)
            {
                GameObject draggingGameObject = UnityUtils.AddChild(canvas.gameObject);
                draggingGameObject.name = gameObject.name;
                draggingGameObject.transform.SetAsLastSibling();

                Image image = draggingGameObject.AddComponent <Image>();
                image.raycastTarget = false;
                image.sprite        = _draggableImage.sprite;
                image.SetNativeSize();

                _draggingRectTransform = draggingGameObject.GetComponent <RectTransform>();

                if (dragOnSurfaces)
                {
                    _draggingPlane = transform as RectTransform;
                }
                else
                {
                    _draggingPlane = canvas.transform as RectTransform;
                }

                OnDrag(eventData);

                onBeginDrag.Call(draggingGameObject);
            }
        }
Esempio n. 8
0
 public void Cleanup()
 {
     foreach (uint current in this.delayTimers.Values)
     {
         Service.ViewTimerManager.KillViewTimer(current);
     }
     this.delayTimers.Clear();
     foreach (ShieldBuildingInfo current2 in this.buildings.Values)
     {
         if (current2.Shield != null)
         {
             UnityEngine.Object.Destroy(current2.Shield.transform.root.gameObject);
             current2.Shield = null;
         }
         if (current2.Spark != null)
         {
             UnityEngine.Object.Destroy(current2.Spark.transform.root.gameObject);
             current2.Spark = null;
         }
         if (current2.Destruction != null)
         {
             UnityEngine.Object.Destroy(current2.Destruction.transform.root.gameObject);
             current2.Destruction = null;
         }
         if (current2.Generator != null)
         {
             UnityEngine.Object.Destroy(current2.Generator.transform.root.gameObject);
             current2.Generator = null;
         }
         if (current2.Top != null)
         {
             UnityEngine.Object.Destroy(current2.Top.transform.root.gameObject);
             current2.Top = null;
         }
         if (current2.DecalMaterial != null)
         {
             UnityUtils.DestroyMaterial(current2.DecalMaterial);
             current2.DecalMaterial = null;
         }
         if (current2.ShieldMaterial != null)
         {
             UnityUtils.DestroyMaterial(current2.ShieldMaterial);
             current2.ShieldMaterial = null;
         }
         if (current2.ShieldDisolveEffect != null)
         {
             current2.ShieldDisolveEffect.Cleanup();
             current2.ShieldDisolveEffect = null;
         }
         int i     = 0;
         int count = current2.AssetHandles.Count;
         while (i < count)
         {
             Service.AssetManager.Unload(current2.AssetHandles[i]);
             i++;
         }
         current2.AssetHandles = null;
     }
     this.buildings.Clear();
 }
Esempio n. 9
0
    public static void CreateScript()
    {
        string copyPath = UnityUtils.GetSelectedPath() + "/BindableScript.cs";

        if (File.Exists(copyPath) == false)           // do not overwrite
        {
            using (StreamWriter outfile =
                       new StreamWriter(copyPath))
            {
                outfile.WriteLine("using UnityEngine;");
                outfile.WriteLine("");
                outfile.WriteLine("public class BindableScript : BindableMonoBehavior {");
                outfile.WriteLine("    ");
                outfile.WriteLine("    ");
                outfile.WriteLine("    // Use this for initialization");
                outfile.WriteLine("    void Start () {");
                outfile.WriteLine("        ");
                outfile.WriteLine("    }");
                outfile.WriteLine("    ");
                outfile.WriteLine("    ");
                outfile.WriteLine("    // Update is called once per frame");
                outfile.WriteLine("    void Update () {");
                outfile.WriteLine("        ");
                outfile.WriteLine("    }");
                outfile.WriteLine("}");
            }
        }
        AssetDatabase.Refresh();
    }
Esempio n. 10
0
 public void UncombineMesh()
 {
     if (this.isDisabled)
     {
         return;
     }
     if (this.IsMeshCombined())
     {
         GameObject[] children = UnityUtils.GetChildren(this.containerObject);
         int          i        = 0;
         int          num      = children.Length;
         while (i < num)
         {
             children[i].transform.parent = null;
             this.meshCombinerGameObjectPool.ReturnToPool(children[i]);
             i++;
         }
         foreach (Renderer current in this.renderers)
         {
             if (current != null)
             {
                 current.enabled = true;
             }
         }
         this.renderers = null;
     }
 }
Esempio n. 11
0
        private static void DestroyMeshCombinerGameObject(GameObject gameObject)
        {
            MeshFilter component = gameObject.GetComponent <MeshFilter>();

            UnityUtils.DestroyMesh(component.sharedMesh);
            UnityEngine.Object.Destroy(gameObject);
        }
Esempio n. 12
0
    /**
     * This Awake method block is the heart of a singleton. Don't play with.
     */
    void Awake()
    {
        if (!instance)
        {
            instance = this;
            DontDestroyOnLoad(gameObject);

            gameControllerScript = UnityUtils.FindComponentOn("ZombieController");

            playerManager = gameObject.GetComponent <PlayerManager>();

            //ugly hack?
            stateManager = gameObject.GetComponent <StateManager>();
            stateManager.DetermineScene();
            stateManager.SetState();
            if (stateManager.currentState == StateManager.gameState.GAMEPLAY)
            {
                vehicle = stateManager.LoadVehicle();
            }

            playerManager.stateManager = stateManager;

            levelController = GetComponent <LevelController>();

            zombWaveController = GetComponent <ZombWaveController>();
            analyticsManager   = gameObject.GetComponent <AnalyticsManager>();
        }
        else
        {
            Destroy(gameObject);
        }
    }
Esempio n. 13
0
        public void Emit(GameObject obj)
        {
            var xPos = UnityEngine.Random.Range(transform.position.x - (EmissionRangeWidth / 2), transform.position.x + (EmissionRangeWidth / 2));
            var yPos = UnityEngine.Random.Range(transform.position.y - (EmissionRangeHeight / 2), transform.position.y + (EmissionRangeHeight / 2));

            var inst = Instantiate(obj, transform.parent);

            inst.transform.position = new Vector3(xPos, yPos, transform.position.z);

            // Update our limits if necessary
            if (limits.ContainsKey(obj.name))
            {
                // Add to our tracked instance dictionary
                instances[obj.name].Add(inst);

                var limit = limits[obj.name].Limit;

                if (instances[obj.name].Count() > limit)
                {
                    if (UnityUtils.Exists(instances[obj.name].First()))
                    {
                        // destroy the first (oldest) instance in the list if it isn't already destroyed.
                        Destroy(instances[obj.name].First());
                    }
                    // remove from the list, shifting all other elements
                    instances[obj.name].Remove(instances[obj.name].First());
                }
            }
        }
 public MeterShaderComponent(GameObject gameObject)
 {
     this.meterObject   = gameObject;
     this.meterMaterial = UnityUtils.EnsureMaterialCopy(this.meterObject.GetComponent <Renderer>());
     this.UpdatePercentage(0f);
     this.FillSize = 0;
 }
Esempio n. 15
0
        public void Cleanup()
        {
            if (this.Entity == null)
            {
                return;
            }
            Service.Get <ViewTimeEngine>().UnregisterFrameTimeObserver(this);
            GameObjectViewComponent gameObjectViewComponent = this.Entity.Get <GameObjectViewComponent>();

            if (gameObjectViewComponent != null)
            {
                gameObjectViewComponent.DetachGameObject(this.name);
            }
            if (this.material != null)
            {
                UnityUtils.DestroyMaterial(this.material);
                this.material = null;
            }
            if (this.view != null)
            {
                UnityEngine.Object.Destroy(this.view);
                this.view = null;
            }
            if (this.heroHandle != AssetHandle.Invalid)
            {
                Service.Get <AssetManager>().Unload(this.heroHandle);
                this.heroHandle = AssetHandle.Invalid;
            }
            this.Entity = null;
            this.hero   = null;
            this.name   = null;
            this.loaded = false;
            this.fading = false;
        }
Esempio n. 16
0
        private void RebuildIndicators()
        {
            if (!viewStateController)
            {
                return;
            }
            if (!togglePrefab)
            {
                return;
            }

            // Destroy old ones
            while (transform.childCount != 0)
            {
                DestroyImmediate(transform.GetChild(0).gameObject);
            }

            // Add new ones
            for (int i = 0; i < viewStateController.states.Count; i++)
            {
                var toggle = UnityUtils.Instantiate <Toggle>(togglePrefab);
                toggle.transform.SetParent(transform, false);
                toggle.onValueChanged.AddListener(b => OnToggleValueChanged(b, toggle));
            }

            // Remember this
            lastStateCount = viewStateController.states.Count;
        }
Esempio n. 17
0
 protected void DestroyRenderObjects()
 {
     this.unityCamera.enabled = false;
     if (this.srcRenderTexture != null)
     {
         Service.Get <CameraManager>().ReleaseRenderTexture(this.srcRenderTexture, false);
         this.srcRenderTexture = null;
     }
     if (this.dstRenderTexture != null)
     {
         Service.Get <CameraManager>().ReleaseRenderTexture(this.dstRenderTexture, false);
         this.dstRenderTexture = null;
     }
     if (this.quadMesh != null)
     {
         UnityUtils.DestroyMesh(this.quadMesh);
         this.quadMesh = null;
     }
     if (this.quadMaterial != null)
     {
         UnityUtils.DestroyMaterial(this.quadMaterial);
         this.quadMaterial = null;
     }
     if (this.quadGameObject != null)
     {
         UnityEngine.Object.Destroy(this.quadGameObject);
         this.quadGameObject = null;
         this.quadMaterial   = null;
     }
 }
Esempio n. 18
0
    /// <summary>
    /// Shows or hides the active bodypart of the current move to play.
    /// </summary>
    /// <param name="show">If set to <c>true</c> show.</param>
    public void ShowActiveBodypart(bool show)
    {
        if (this.moveToPlay == null)
        {
            return;             //Do nothing if there is no move to play.
        }
        Transform bodypart = UnityUtils.RecursiveFind(transform, this.moveToPlay.GetActiveBodypart());
        Transform shield   = UnityUtils.RecursiveFind(transform, this.moveToPlay.GetActiveBodypart().Replace(" ", "") + "Shield");

        if (bodypart != null && bodypart.gameObject.GetComponent <ColorModifier> () != null && !moveToPlay.IsBlockMove())
        {
            //Highlight damage dealer if move is not a block move and show true, hide otherwise.
            bodypart.gameObject.GetComponent <ColorModifier> ().SetSelected(show);
        }
        if (shield != null && moveToPlay.IsBlockMove())
        {
            //Show shield if move is a block move and show true, hide otherwise.
            shield.gameObject.GetComponent <SpriteRenderer> ().enabled = show;
            ShieldControl shieldControl = shield.GetComponent <ShieldControl> ();
            if (shieldControl != null)
            {
                shieldControl.UpdateScale(moveToPlay);
            }
        }
    }
Esempio n. 19
0
    private T CreateScreen <T>(string name) where T : BasePopup
    {
        T s = null;

        if (_childs.ContainsKey(name))
        {
            s = _childs[name] as T;
        }
        else
        {
            var prefub = Resources.Load <GameObject>("screens/" + name);

            var obj = UnityUtils.Clone(prefub, _uiRoot);

            s = obj.GetComponent <T>();

            _childs.Add(name, s);
        }

        s.name = name;

        s.gameObject.SetActive(false);

        return(s);
    }
Esempio n. 20
0
        private void OnSnapShotTaken()
        {
            base.RestoreCameras(this.srcCameras, true, false);
            if (this.dstRenderTexture != null)
            {
                UnityUtils.ReleaseTemporaryRenderTexture(this.dstRenderTexture);
                this.dstRenderTexture = null;
            }
            WipeTransition wipeTransition = this.transition;

            if (wipeTransition != WipeTransition.FromBaseToWarboard)
            {
                if (wipeTransition == WipeTransition.FromWarboardToBase)
                {
                    this.SetupDestinationWipeFromWarboardToBase();
                }
            }
            else
            {
                this.SetupDestinationWipeFromBaseToWarboard();
            }
            this.dstRenderTexture = base.PrepareCameras(this.dstCameras);
            this.quadMaterial.SetTexture("_to", this.dstRenderTexture);
            this.takingSnapshot = false;
            if (this.continueWipeRequested)
            {
                this.continueWipeRequested = false;
            }
            else
            {
                Service.ViewTimeEngine.UnregisterFrameTimeObserver(this);
            }
            Service.EventManager.SendEvent(EventId.WipeCameraSnapshotTaken, null);
        }
        protected void SetupCamera(string name, GameObject subject, float sharpness, float width, float height, Vector3 cameraPosition, Vector3 cameraInterest)
        {
            this.DestroyCamera();
            this.cameraGameObject = new GameObject(string.Format("Projector Camera ({0})", new object[]
            {
                name
            }));
            Camera camera = this.cameraGameObject.AddComponent <Camera>();

            camera.fieldOfView     = 10f;
            camera.clearFlags      = CameraClearFlags.Color;
            camera.backgroundColor = new Color(0f, 0f, 0f, 0f);
            camera.depth           = 0f;
            int num = 13;

            this.cameraGameObject.layer = num;
            camera.cullingMask          = 1 << num;
            UnityUtils.SetLayerRecursively(subject, this.cameraGameObject.layer);
            camera.aspect    = 1f;
            camera.eventMask = 0;
            int num2 = Math.Min((int)(width * sharpness), (int)(height * sharpness));

            this.renderTexture = Service.Get <CameraManager>().GetRenderTexture(num2, num2);
            Vector3 vector = (Vector3.up + Vector3.right) * 500f;

            vector.y += (float)this.projectorIndex * 250f;
            this.cameraGameObject.transform.position = vector;
            subject.transform.position = vector - cameraPosition;
            Vector3 worldPosition = subject.transform.position + cameraInterest;

            this.cameraGameObject.transform.LookAt(worldPosition);
            camera.targetTexture = this.renderTexture;
        }
Esempio n. 22
0
    //spawn new grid of gameobjects, each having a single sprite
    private GameObject SpawnGridFrom(List <Sprite> tiles, Sprite tileContainer)
    {
        Vector2 sizeParent = UnityUtils.GetDimensionInPX(tileContainer);
        Vector2 size       = UnityUtils.GetDimensionInPX(tiles[0]);

        GameObject gridContainer = new GameObject("Grid");

        gridContainer.transform.position = this.transform.position;
        gridContainer.transform.parent   = this.transform;

        int count = 0;

        GameObject[,] grid = new GameObject[columns, rows]; //TODO: still magic, TBD...
        for (int y = 0; y < grid.GetLength(1); y++)
        {
            for (int x = 0; x < grid.GetLength(0); x++)
            {
                string     cellName     = transform.name + "Cell_" + count + "_[" + x + "," + y + "]";
                GameObject cell         = SpawnCell(cellName);
                Vector3    cellPosition = new Vector3(-sizeParent.x / 2 + x * size.x + size.x / 2, sizeParent.y / 2 - (y * size.y + size.y / 2), 0);
                cell.transform.position = transform.position + (cellPosition * transform.localScale.x);
                cell.transform.parent   = gridContainer.transform;
                grid[x, y] = cell;
                SpriteRenderer sr = cell.AddComponent <SpriteRenderer>();
                sr.sprite           = tiles[count];
                sr.sortingLayerName = this.sr.sortingLayerName;
                sr.sortingOrder    += 1;
                count++;
            }
        }
        return(gridContainer);
    }
Esempio n. 23
0
 private void GenerateTriggerMaterial()
 {
     if (this.triggerMaterial == null)
     {
         string shaderName = "Scroll_XY_Alpha";
         Shader shader     = Service.AssetManager.Shaders.GetShader(shaderName);
         if (shader == null)
         {
             return;
         }
         this.triggerMaterial = UnityUtils.CreateMaterial(shader);
         this.triggerRadius.GetComponent <Renderer>().sharedMaterial = this.triggerMaterial;
         this.triggerMaterial.color = this.TRIGGER_COLOR;
         this.triggerMaterial.SetFloat("_tint", 1f);
         this.triggerMaterial.SetFloat("_SpeedX", 0f);
         if (this.triggerTexture != null)
         {
             this.AssignTriggerMaterial();
         }
         else if (this.triggerHandle == AssetHandle.Invalid)
         {
             this.triggerRadius.SetActive(false);
             TextureVO textureVO = Service.StaticDataController.Get <TextureVO>("trigger_radius");
             Service.AssetManager.Load(ref this.triggerHandle, textureVO.AssetName, new AssetSuccessDelegate(this.OnTextureLoaded), null, this.triggerMaterial);
         }
     }
 }
Esempio n. 24
0
        public void CreateUnVision()
        {
            //创建碰撞提
            SpecialAreaInSceneData[] areaData = reader.GetSceneEditorElementData <SpecialAreaInSceneData>();
            if (areaData != null && areaData.Length > 0)
            {
                GameObject ptObj = new GameObject("boxcollider");
                UnityUtils.AddChild_Reverse(ptObj, ScenePoint);

                for (int i = 0; i < areaData.Length; i++)
                {
                    GameObject obj = new GameObject(i.ToString());
                    UnityUtils.AddChild_Reverse(obj, ptObj);

                    //调整大小
                    obj.transform.position    = new Vector3(areaData [i].pos [0], areaData [i].pos [1], areaData [i].pos [2]);
                    obj.transform.localScale  = new Vector3(areaData [i].scale [0], areaData [i].scale [1], areaData [i].scale [2]);
                    obj.transform.eulerAngles = new Vector3(areaData [i].rotation [0], areaData [i].rotation [1], areaData [i].rotation [2]);

                    //添加碰撞
                    BoxCollider box = obj.AddComponent <BoxCollider>();
                    box.center = Vector3.zero;
                    box.size   = Vector3.one;
                }
            }
        }
Esempio n. 25
0
        private void CleanUp()
        {
            AnimController animController = Service.Get <AnimController>();

            if (this.animAlphaIn != null)
            {
                animController.CompleteAnim(this.animAlphaIn);
                this.animAlphaIn = null;
            }
            if (this.animAlphaOut != null)
            {
                animController.CompleteAnim(this.animAlphaOut);
                this.animAlphaOut = null;
            }
            if (this.gameObject != null)
            {
                MeshFilter component = this.gameObject.GetComponent <MeshFilter>();
                component.sharedMesh = null;
            }
            if (this.mesh != null)
            {
                UnityUtils.DestroyMesh(this.mesh);
                this.mesh = null;
            }
            if (this.gameObjectExists)
            {
                this.gameObject.SetActive(false);
                this.gameObjectExists = false;
            }
            this.gameObjectVisible = false;
            this.initialized       = false;
        }
Esempio n. 26
0
    public void TakeUnit(GameObject prefab, Commander commander)
    {
        Cancel();
        Reset();

        GameObject placementPrefab = commander.GeneratePrefab(prefab);

        _model = UnityUtils.InstantiateMockGO(placementPrefab);
        _model.transform.SetParent(transform);
        _model.transform.position = transform.position;

        _prefab             = prefab;
        _commander          = commander;
        _placementCheckSize = _commander.GetUnitPlacementCheckSize(_prefab);
        _unit = prefab.GetComponent <Unit>();

        AIController controller = placementPrefab.GetComponent <AIController>();
        float        unitRange  = 0f;

        if (controller)
        {
            unitRange = controller.AttackRange;
        }

        RangeIndicator.transform.localScale = new Vector3(unitRange, unitRange, unitRange);
    }
Esempio n. 27
0
        public void Set(int slot, MapData map, string pb)
        {
            nameField.text       = map.name;
            authorField.text     = map.author;
            previewImage.texture = map.previewImage;
            pbField.text         = pb;
            loadButton.onClick.AddListener(() => OnPlayableMapClick(map));
            pbButton.onClick.AddListener(() =>
            {
                LeaderboardWindow leaderboard = (LeaderboardWindow)GameMenu.SingletonInstance.AddWindow(Window.LEADERBOARD);
                // TODO: load leaderboards at pb index
                leaderboard.LoadMap(map);
            });
            wrButton.onClick.AddListener(() =>
            {
                LeaderboardWindow leaderboard = (LeaderboardWindow)GameMenu.SingletonInstance.AddWindow(Window.LEADERBOARD);
                leaderboard.LoadMap(map);
            });

            StartCoroutine(UnityUtils.RunWhenDone(Leaderboard.GetRecord(map), (request) =>
            {
                if (!request.Error)
                {
                    if (request.Result.Length == 1)
                    {
                        SetWrText(request.Result[0]);
                    }
                }
            }));
        }
Esempio n. 28
0
 private bool TrySetMaterial()
 {
     Renderer[] componentsInChildren = this.view.GetComponentsInChildren <Renderer>();
     if (componentsInChildren != null)
     {
         int i   = 0;
         int num = componentsInChildren.Length;
         while (i < num)
         {
             Renderer renderer = componentsInChildren[i];
             if (renderer != null)
             {
                 Material x = UnityUtils.EnsureMaterialCopy(renderer);
                 if (x != null)
                 {
                     this.material = x;
                     this.SetMaterialSaturation(1f);
                     return(true);
                 }
             }
             i++;
         }
     }
     return(false);
 }
 private void OnEffectLoaded(object asset, object cookie)
 {
     this.effectObj     = UnityEngine.Object.Instantiate <GameObject>(asset as GameObject);
     this.troopCardPS   = this.effectObj.transform.FindChild("CardFX").GetComponent <ParticleSystem>();
     this.shuttleGlowPS = this.effectObj.transform.FindChild("UnderGlow").GetComponent <ParticleSystem>();
     this.effectObj.SetActive(false);
     if (this.troopCardPS == null || !UnityUtils.HasRendererMaterial(this.troopCardPS.GetComponent <Renderer>()))
     {
         Service.Get <StaRTSLogger>().WarnFormat("Transport troop effect error: Particle system {0} not found in {1}", new object[]
         {
             "CardFX",
             "troop_card_spawn"
         });
         this.showFullEffect = false;
     }
     if (this.shuttleGlowPS == null)
     {
         Service.Get <StaRTSLogger>().WarnFormat("Transport troop effect error: Particle system {0} not found in {1}", new object[]
         {
             "UnderGlow",
             "troop_card_spawn"
         });
         this.showFullEffect = false;
     }
     this.TryShowEffect();
 }
Esempio n. 30
0
    private static void InitBaseMd5File()
    {
        m_baseMd5Dic = new Dictionary <string, string>();
        m_md5DiffDic = new Dictionary <string, int>();
        if (!File.Exists(m_baseMd5Str))
        {
            return;
        }
        string filesText = UnityUtils.ReadLocalTxt(m_baseMd5Str);

        string[] files = filesText.Split('\n');

        for (int i = 0; i < files.Length; i++)
        {
            if (files[i].Equals(""))
            {
                continue;
            }
            string[] names = files[i].Split('|');
            if (!m_baseMd5Dic.ContainsKey(names[0]))
            {
                m_baseMd5Dic.Add(names[0], names[1].TrimEnd("\r".ToCharArray()));
            }
        }
    }