상속: MonoBehaviour
예제 #1
0
        internal static ChromaBehaviour CreateNewInstance()
        {
            IsLoadingSong = true;
            ChromaLogger.Log("ChromaBehaviour attempting creation.", ChromaLogger.Level.DEBUG);
            ClearInstance();

            if (SceneUtils.IsTargetGameScene(SceneManager.GetActiveScene().buildIndex))
            {
                GameObject      instanceObject = new GameObject("ChromaBehaviour");
                ChromaBehaviour behaviour      = instanceObject.AddComponent <ChromaBehaviour>();
                _instance = behaviour;
                ChromaLogger.Log("ChromaBehaviour instantiated.", ChromaLogger.Level.DEBUG);
                return(behaviour);
            }
            else
            {
                ChromaLogger.Log("Invalid scene index.");
                return(null);
            }
        }
예제 #2
0
        public static void RefreshLights()
        {
            try {
                ChromaLogger.Log("Refreshing Lights");

                Color ambientLight = ColourManager.LightAmbient;
                Color red          = ColourManager.LightAmbient;
                Color blue         = ColourManager.LightAmbient;
                Color redLight     = ColourManager.LightAmbient;
                Color blueLight    = ColourManager.LightAmbient;
                Color platform     = ColourManager.LightAmbient;
                Color signA        = ColourManager.LightAmbient;
                Color signB        = ColourManager.LightAmbient;
                Color laser        = ColourManager.LaserPointerColour;

                string ambientSound = null;

                RefreshLightsEvent?.Invoke(ref ambientLight, ref red, ref blue, ref redLight, ref blueLight, ref platform, ref signA, ref signB, ref laser, ref ambientSound);

                //ColourManager.RecolourAllLights(ColourManager.LightA, ColourManager.LightB);
                ResetAllLights();
                ColourManager.RecolourAmbientLights(ambientLight);
                if (!SceneUtils.IsTargetGameScene(SceneManager.GetActiveScene()))
                {
                    ColourManager.RecolourNeonSign(signA, signB);
                    ColourManager.RecolourMenuStuff(red, blue, redLight, blueLight, platform, laser);
                }

                if (ambientSound == null)
                {
                    AudioUtil.Instance.StopAmbianceSound();
                }
                else
                {
                    AudioUtil.Instance.StartAmbianceSound(ambientSound);
                }
            } catch (Exception e) {
                ChromaLogger.Log("Error refreshing lights!");
                ChromaLogger.Log(e, ChromaLogger.Level.WARNING);
            }
        }
예제 #3
0
    private bool OnNavigateBack()
    {
        UnityEngine.Debug.Log("navigating back!");
        if (!this.m_DoneButton.m_button.activeSelf)
        {
            return(false);
        }
        foreach (GameObject obj2 in this.m_RewardObjects)
        {
            if (obj2 != null)
            {
                PlayMakerFSM rfsm = obj2.GetComponent <PlayMakerFSM>();
                if (rfsm != null)
                {
                    rfsm.SendEvent("Death");
                }
                foreach (UberText text in obj2.GetComponentsInChildren <UberText>())
                {
                    object[] args = new object[] { "alpha", 0f, "time", 0.8f, "includechildren", true, "easetype", iTween.EaseType.easeInOutCubic };
                    iTween.FadeTo(text.gameObject, iTween.Hash(args));
                }
                RewardCard componentInChildren = obj2.GetComponentInChildren <RewardCard>();
                if (componentInChildren != null)
                {
                    componentInChildren.Death();
                }
            }
        }
        SceneUtils.EnableColliders(this.m_DoneButton.gameObject, false);
        this.m_DoneButton.RemoveEventListener(UIEventType.RELEASE, new UIEvent.Handler(this.OnDoneButtonPressed));
        Spell component = this.m_DoneButton.m_button.GetComponent <Spell>();

        component.AddFinishedCallback(new Spell.FinishedCallback(this.OnDoneButtonHidden));
        component.ActivateState(SpellStateType.DEATH);
        CollectionManager.Get().RemoveAchievesCompletedListener(new CollectionManager.DelOnAchievesCompleted(this.OnCollectionAchievesCompleted));
        if (this.m_addRewardsToCacheValues)
        {
            this.AddRewardsToCacheValues();
        }
        return(true);
    }
예제 #4
0
        string value2Str(double value, ValueType valueType)
        {
            var res = "";

            switch (valueType)
            {
            case ValueType.Number: return(value.ToString());

            case ValueType.Double: return(SceneUtils.double2Str(value));

            case ValueType.Percent: return(SceneUtils.double2Perc(value));

            case ValueType.Sign:
                res = value.ToString();
                if (value > 0)
                {
                    res = "+" + res;
                }
                break;

            case ValueType.SignDouble:
                res = SceneUtils.double2Str(value);
                if (value > 0)
                {
                    res = "+" + res;
                }
                break;

            case ValueType.SignPercent:
                res = SceneUtils.double2Perc(value);
                if (value > 0)
                {
                    res = "+" + res;
                }
                break;

            case ValueType.TimeSpan:
                return(SceneUtils.time2Str(value / 1000.0));
            }
            return(res);
        }
 public void Init()
 {
     if (this.m_heroActor == null)
     {
         this.m_heroActor = AssetLoader.Get().LoadActor("Card_Play_Hero", false, false).GetComponent <Actor>();
         this.m_heroActor.SetUnlit();
         this.m_heroActor.Show();
         this.m_heroActor.GetHealthObject().Hide();
         this.m_heroActor.GetAttackObject().Hide();
         GameUtils.SetParent(this.m_heroActor, this.m_heroContainer, true);
         SceneUtils.SetLayer(this.m_heroActor, this.m_heroContainer.layer);
     }
     if (this.m_heroPowerActor == null)
     {
         this.m_heroPowerActor = AssetLoader.Get().LoadActor("Card_Play_HeroPower", false, false).GetComponent <Actor>();
         this.m_heroPowerActor.SetUnlit();
         this.m_heroPowerActor.Show();
         GameUtils.SetParent(this.m_heroPowerActor, this.m_heroPowerContainer, true);
         SceneUtils.SetLayer(this.m_heroPowerActor, this.m_heroPowerContainer.layer);
     }
 }
예제 #6
0
        private void GetSwizzledTarget()
        {
            if (!string.IsNullOrEmpty(SavedTarget))
            {
                var goList = SceneUtils.FindAllGameObjects(SavedTarget);
                if (goList.Count == 1)
                {
                    Target = goList[0].transform;
                }
                else if (goList.Count == 0)
                {
                    CDebug.LogEx(string.Format("Couldn't find target '{0}' when restoring {1}", SavedTarget, this.name), LogLevel.Error, this);
                }
                else
                {
                    CDebug.LogEx(string.Format("Found multiple target '{0}' when restoring {1}", SavedTarget, this.name), LogLevel.Error, this);
                }

                SavedTarget = null;
            }
        }
예제 #7
0
    public static void LaunchSavedGame(MonoBehaviour ReferenceScript, string SaveGame = "AutoSave.bin")
    {
        Nullable <SaveManager.SaveGame> SavedGame = SaveManager.LoadGame(SaveGame);

        if (SavedGame == null)
        {
            UiDialog.ShowWarningDialog("Couldn't load " + SaveGame + "...try to start a new game....");
            return;
        }
        Debug.Log("LaunchSavedGame Loading " + SaveGame);
        if (GameHandler.Instance)
        {
            GameHandler.Instance.CleanUp();
            //GameHandler.Instance.CleanUp();
        }
        Debug.Log("Loading scene: " + SavedGame.Value.SceneName);
        //GameObject FantomGameObject = new GameObject();
        //MonoBehaviour Dummy = FantomGameObject.AddComponent<MonoBehaviour>();
        InputManager.Instance.StartCoroutine(SceneUtils.LoadSceneAsync(SavedGame.Value));
        //Debug.Log("GameHandler resuming load: " + GameHandler.Instance.IsPaused);
    }
예제 #8
0
    // Start is called before the first frame update
    void Awake()
    {
        SceneUtils.MakeSureSceneIsLoaded(MenuScene);
        SceneUtils.MakeSureSceneIsLoaded(GameScene, active: true);

        SceneUtils.SceneLoaded += s =>
        {
            if (s == MenuScene)
            {
                BindMainMenu();
                return;
            }
            if (s == GameOverScene)
            {
                BindGameOver();
                return;
            }
        };

        OriginShifter.Shifted += OnShifted;
    }
예제 #9
0
    public override void OnInspectorGUI()
    {
        EditorGUILayout.PropertyField(_widthProperty);
        EditorGUILayout.PropertyField(_heightProperty);

        if (GUILayout.Button("MakeShot"))
        {
            MakeShot();
        }

        if (GUILayout.Button("Move camera to editor view"))
        {
            Camera camera = _gameObject.GetComponent <Camera>();
            if (camera)
            {
                SceneUtils.MoveCameraToEditorView(camera);
            }
        }

        serializedObject.ApplyModifiedProperties();
    }
    public override void Show()
    {
        base.Show();
        this.InitInfo();
        this.UpdateAll(this.m_popupInfo);
        Transform transform = base.transform;

        transform.localPosition += this.m_popupInfo.m_offset;
        if (this.m_popupInfo.m_layerToUse.HasValue)
        {
            SceneUtils.SetLayer(this, this.m_popupInfo.m_layerToUse.Value);
        }
        if (this.m_popupInfo.m_disableBlocker)
        {
            this.m_clickCatcher.SetActive(false);
        }
        base.DoShowAnimation();
        bool active = ((this.m_popupInfo == null) || !this.m_popupInfo.m_layerToUse.HasValue) || (((GameLayer)this.m_popupInfo.m_layerToUse.Value) == GameLayer.UI);

        UniversalInputManager.Get().SetSystemDialogActive(active);
    }
 private void ActivateArrow(bool active)
 {
     this.m_isActive = active;
     SceneUtils.EnableRenderers(this.m_arrow.gameObject, false);
     this.m_hunterReticle.SetActive(false);
     if (active)
     {
         if (this.m_ReticleType == TARGET_RETICLE_TYPE.DefaultArrow)
         {
             SceneUtils.EnableRenderers(this.m_arrow.gameObject, active && this.m_showArrow);
         }
         else if (this.m_ReticleType == TARGET_RETICLE_TYPE.HunterReticle)
         {
             this.m_hunterReticle.SetActive(active && this.m_showArrow);
         }
         else
         {
             UnityEngine.Debug.LogError("Unknown Target Reticle Type!");
         }
     }
 }
예제 #12
0
        /// <summary>
        /// 击中判断
        /// </summary>
        /// <param name="sp">屏幕位置点</param>
        /// <param name="eventCamera">摄像机</param>
        /// <returns>是否击中</returns>
        public bool IsRaycastLocationValid(Vector2 sp, Camera eventCamera)
        {
            if (raycastTarget)
            {
                // sp 转换为当前 RT 内的点的位置
                Vector2 local = SceneUtils.screen2Local(
                    sp, rectTransform, eventCamera);

                int   cnt        = getEdgeCount();
                float deltaAngle = 360f / cnt;

                for (int i = 0; i < cnt; i++)
                {
                    if (isInPolygon(i, deltaAngle, local))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
 public void OnLoad(SpellState state)
 {
     if (this.m_Target == Target.AS_SPECIFIED)
     {
         if (this.m_GameObject == null)
         {
             Debug.LogError("Error: spell state anim target has a null game object after load");
         }
     }
     else if (this.m_Target == Target.ACTOR)
     {
         Actor actor = SceneUtils.FindComponentInParents <Actor>(state.transform);
         if ((actor == null) || (actor.gameObject == null))
         {
             Debug.LogError("Error: spell state anim target has a null game object after load");
         }
         else
         {
             this.m_GameObject = actor.gameObject;
             this.SetupAnimation();
         }
     }
     else if (this.m_Target == Target.ROOT_OBJECT)
     {
         Actor actor2 = SceneUtils.FindComponentInParents <Actor>(state.transform);
         if ((actor2 == null) || (actor2.gameObject == null))
         {
             Debug.LogError("Error: spell state anim target has a null game object after load");
         }
         else
         {
             this.m_GameObject = actor2.GetRootObject();
             this.SetupAnimation();
         }
     }
     else
     {
         Debug.LogWarning("Error: unimplemented spell anim target");
     }
 }
 private void OnActorLoaded(string name, GameObject go, object callbackData)
 {
     if (go == null)
     {
         UnityEngine.Debug.LogWarning(string.Format("DeckHelper.OnActorLoaded() - FAILED to load actor \"{0}\"", name));
     }
     else
     {
         Actor component = go.GetComponent <Actor>();
         if (component == null)
         {
             UnityEngine.Debug.LogWarning(string.Format("DeckHelper.OnActorLoaded() - ERROR actor \"{0}\" has no Actor component", name));
         }
         else
         {
             component.transform.parent = base.transform;
             SceneUtils.SetLayer(component, base.gameObject.layer);
             ActorLoadCallback callback  = (ActorLoadCallback)callbackData;
             RDMDeckEntry      choice    = callback.choice;
             EntityDef         entityDef = choice.EntityDef;
             CardDef           cardDef   = callback.cardDef;
             CardFlair         cardFlair = choice.Flair;
             component.SetEntityDef(entityDef);
             component.SetCardDef(cardDef);
             component.SetCardFlair(cardFlair);
             component.UpdateAllComponents();
             component.gameObject.name = cardDef.name + "_actor";
             component.GetCollider().gameObject.AddComponent <DeckHelperVisual>().SetActor(component);
             this.m_actors.Add(component);
             if (this.HaveActorsForAllChoices())
             {
                 this.PositionAndShowChoices();
             }
             else
             {
                 component.Hide();
             }
         }
     }
 }
예제 #15
0
    // Use this for initialization
    public virtual void Start()
    {
        alienTargetManager = SceneUtils.FindObject <AlienTargetManager>();
        alienInputActions  = AlienInputActions.CreateWithDefaultBindings();
        leftStickControl   = SceneUtils.FindObject <LeftStickControl>();
        animationManager   = GetComponentInChildren <AnimationManager2D>();

        if (this.transform.Find("Sounds"))
        {
            if (this.transform.Find("Sounds/ExplosionSound"))
            {
                explosionSound = this.transform.Find("Sounds/ExplosionSound").GetComponent <SoundObject>();
            }

            if (this.transform.Find("Sounds/FlingSound"))
            {
                flingSound = this.transform.Find("Sounds/FlingSound").GetComponent <SoundObject>();
            }
        }
        if (this.transform.Find("ShootPosition"))
        {
            shootPosition = this.transform.Find("ShootPosition");
        }
        else
        {
            shootPosition = this.transform;
        }

        if (isControlled)
        {
            OnControlled();
        }

        if (this.transform.Find("BloodAnimations"))
        {
            bloodAnimations =
                this.transform.Find("BloodAnimations")
                .GetComponentsInChildren <Animation2D>();
        }
    }
    protected override void Awake()
    {
        base.Awake();
        string     name = (UniversalInputManager.UsePhoneUI == null) ? "DeckCardBar" : "DeckCardBar_phone";
        GameObject obj2 = AssetLoader.Get().LoadActor(name, false, false);

        if (obj2 == null)
        {
            Debug.LogWarning(string.Format("DeckTrayDeckTileVisual.OnDeckTileActorLoaded() - FAILED to load actor \"{0}\"", name));
        }
        else
        {
            this.m_actor = obj2.GetComponent <CollectionDeckTileActor>();
            if (this.m_actor == null)
            {
                Debug.LogWarning(string.Format("DeckTrayDeckTileVisual.OnDeckTileActorLoaded() - ERROR game object \"{0}\" has no CollectionDeckTileActor component", name));
            }
            else
            {
                GameUtils.SetParent((Component)this.m_actor, (Component)this, false);
                this.m_actor.transform.localEulerAngles = new Vector3(0f, 180f, 0f);
                UIBScrollableItem component = this.m_actor.GetComponent <UIBScrollableItem>();
                if (component != null)
                {
                    component.SetCustomActiveState(new UIBScrollableItem.ActiveStateCallback(this.IsInUse));
                }
                this.SetUpActor();
                if (base.gameObject.GetComponent <BoxCollider>() == null)
                {
                    this.m_collider        = base.gameObject.AddComponent <BoxCollider>();
                    this.m_collider.size   = this.BOX_COLLIDER_SIZE;
                    this.m_collider.center = this.BOX_COLLIDER_CENTER;
                }
                this.Hide();
                SceneUtils.SetLayer(base.gameObject, LAYER);
                base.SetDragTolerance(5f);
            }
        }
    }
예제 #17
0
        /// <summary>
        /// 处理Y缩放类型的显示项
        /// </summary>
        /// <param name="item">显示项</param>
        /// <param name="value">值</param>
        void processScaleYDisplayItem(DisplayItem item, JsonData value)
        {
            if (!item.obj.activeSelf)
            {
                return;
            }
            var transform = item.obj.transform;

            if (transform == null)
            {
                return;
            }

            var rate = DataLoader.load <float>(value);
            var ani  = SceneUtils.ani(item.obj);

            var ori    = transform.localScale;
            var target = new Vector3(ori.x, rate, ori.z);

            // 动画
            if (immediately || !item.animated)
            {
                transform.localScale = target;
            }
            else
            {
                var aniItem = SceneUtils.get <AnimationExtend>(item.obj);
                if (aniItem == null)
                {
                    var tmpAni = AnimationUtils.createAnimation();
                    tmpAni.addCurve(typeof(Transform), "m_LocalScale.y", ori.y, rate);
                    tmpAni.setupAnimation(ani);
                }
                else
                {
                    aniItem.scaleTo(target, play: true);
                }
            }
        }
예제 #18
0
    private static void FindMissingScriptsInScenes(ref int missingCount)
    {
        EditorUtility.DisplayProgressBar("Searching scenes", "", 0.0f);

        if (EditorApplication.isPlaying)
        {
            FindMissingScriptsInScene(EditorSceneManager.GetActiveScene(), ref missingCount);
            FindMissingScriptsInScene(SceneUtils.GetDontDestroyOnLoadScene(), ref missingCount);
        }
        else
        {
            string currentScenePath = EditorSceneManager.GetActiveScene().path;

            string[] scenePaths = System.IO.Directory.GetFiles(Path.Combine(Application.dataPath, SCENES_FOLDER_PATH), "*.unity", System.IO.SearchOption.AllDirectories);
            foreach (var scenePath in scenePaths)
            {
                Scene scene = EditorSceneManager.OpenScene(scenePath, OpenSceneMode.Single);
                FindMissingScriptsInScene(scene, ref missingCount);
            }
            EditorSceneManager.OpenScene(currentScenePath, OpenSceneMode.Single);
        }
    }
예제 #19
0
        /// <summary>
        /// 设置图片链接
        /// </summary>
        /// <param name="image">图片</param>
        /// <param name="index">索引</param>
        Vector2 setImageLink(Image image, int index)
        {
            var obj = image.gameObject;
            var btn = SceneUtils.button(obj);

            // 隐藏
            image.color = new Color(0.75f, 0.75f, 1, 0.5f);
            btn.onClick.RemoveAllListeners();
            btn.onClick.AddListener(() => {
                Debug.Log("setImageLink: " + index);
                if (textObj.onImageLinkClick != null)
                {
                    textObj.onImageLinkClick.Invoke(index);
                }
                else if (textObj.imageContainer != null)
                {
                    textObj.imageContainer.select(index);
                }
            }
                                    );
            return(textObj.meansure(replace(index, true)));
        }
예제 #20
0
    protected override void OnAction(SpellStateType prevStateType)
    {
        base.OnAction(prevStateType);
        Entity     entity = base.GetSourceCard().GetEntity();
        Actor      actor  = SceneUtils.FindComponentInParents <Actor>(this);
        GameObject main   = this.m_minionPieces.m_main;
        bool       flag   = entity.HasTag(GAME_TAG.PREMIUM);

        if (flag)
        {
            main = this.m_minionPieces.m_premium;
            SceneUtils.EnableRenderers(this.m_minionPieces.m_main, false);
        }
        GameObject portraitMesh = actor.GetPortraitMesh();

        main.GetComponent <Renderer>().material = portraitMesh.GetComponent <Renderer>().sharedMaterial;
        main.SetActive(true);
        SceneUtils.EnableRenderers(main, true);
        if (entity.HasTaunt())
        {
            if (flag)
            {
                this.m_minionPieces.m_taunt.GetComponent <Renderer>().material = this.m_premiumTauntMaterial;
            }
            this.m_minionPieces.m_taunt.SetActive(true);
            SceneUtils.EnableRenderers(this.m_minionPieces.m_taunt, true);
        }
        if (entity.IsElite())
        {
            if (flag)
            {
                this.m_minionPieces.m_legendary.GetComponent <Renderer>().material = this.m_premiumEliteMaterial;
            }
            this.m_minionPieces.m_legendary.SetActive(true);
            SceneUtils.EnableRenderers(this.m_minionPieces.m_legendary, true);
        }
        this.m_attack.SetGameStringText(entity.GetATK().ToString());
        this.m_health.SetGameStringText(entity.GetHealth().ToString());
    }
    private Actor GetAndPositionNewUpsideDownActor(Actor oldActor, bool fromPage)
    {
        Actor andPositionNewActor = this.GetAndPositionNewActor(oldActor, 1);

        SceneUtils.SetLayer(andPositionNewActor.gameObject, GameLayer.IgnoreFullScreenEffects);
        if (fromPage)
        {
            andPositionNewActor.transform.position         = oldActor.transform.position + new Vector3(0f, -2f, 0f);
            andPositionNewActor.transform.localEulerAngles = new Vector3(0f, 0f, 180f);
            iTween.RotateTo(andPositionNewActor.gameObject, new Vector3(0f, 350f, 180f), 0.4f);
            object[] objArray1 = new object[] { "name", "GetAndPositionNewUpsideDownActor", "position", this.m_faceDownCardBone.position, "time", 0.4f };
            iTween.MoveTo(andPositionNewActor.gameObject, iTween.Hash(objArray1));
            iTween.ScaleTo(andPositionNewActor.gameObject, this.m_faceDownCardBone.localScale, 0.4f);
            return(andPositionNewActor);
        }
        andPositionNewActor.transform.localEulerAngles = new Vector3(0f, 350f, 180f);
        andPositionNewActor.transform.position         = this.m_faceDownCardBone.position + new Vector3(0f, -6f, 0f);
        andPositionNewActor.transform.localScale       = this.m_faceDownCardBone.localScale;
        object[] args = new object[] { "name", "GetAndPositionNewUpsideDownActor", "position", this.m_faceDownCardBone.position, "time", this.m_timeForBackCardToMoveUp, "easetype", this.m_easeTypeForCardMoveUp, "delay", this.m_delayBeforeBackCardMovesUp };
        iTween.MoveTo(andPositionNewActor.gameObject, iTween.Hash(args));
        return(andPositionNewActor);
    }
예제 #22
0
    /// <summary>
    /// Drawing the 'SceneReference' property
    /// </summary>

    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        var sceneAssetProperty = GetSceneAssetProperty(property);

        // Draw the Box Background
        position.height -= footerHeight;
        GUI.Box(EditorGUI.IndentedRect(position), GUIContent.none, EditorStyles.helpBox);
        position        = boxPadding.Remove(position);
        position.height = lineHeight;

        // Draw the main Object field
        label.tooltip = "The actual Scene Asset reference.\nOn serialize this is also stored as the asset's path.";

        EditorGUI.BeginProperty(position, GUIContent.none, property);
        EditorGUI.BeginChangeCheck();
        int sceneControlID = GUIUtility.GetControlID(FocusType.Passive);
        var selectedObject = EditorGUI.ObjectField(position, label, sceneAssetProperty.objectReferenceValue, typeof(SceneAsset), false);

        SceneUtils.SubScene buildScene = SceneUtils.GetScene(selectedObject);

        if (EditorGUI.EndChangeCheck())
        {
            sceneAssetProperty.objectReferenceValue = selectedObject;

            //If no valid scene asset was selected, reset the stored path accordingly
            //if (buildScene.scene == null)
            //    GetScenePathProperty(property).stringValue = string.Empty;
        }
        position.y += paddedLine;

        if (buildScene.assetGUID.Empty() == false)
        {
            // Draw the Build Settings Info of the selected Scene
            DrawSceneInfoGUI(position, buildScene, sceneControlID + 1);
        }

        EditorGUI.EndProperty();
    }
예제 #23
0
    IEnumerator End_Level()
    {
        stopGame = true;
        AudioMixerManager._instance.PlayBackgroundSource(false);
        SimpleCameraController2d._instance.StopFollow();
        yield return(new WaitForSeconds(.5f));

        UIController._instance.Run_EndLevelAnimation();
        yield return(new WaitForSeconds(1.5f));

        FadeEffect._instance.Fade_Out();
        SetPlayerPrefsLevelToUnlock();
        if (SceneUtils.Get_CurrentLevelName() != 0)
        {
            SetPlayerPrefsGems();
            SetPlayerPrefsTime();
        }
        yield return(new WaitUntil(() => FadeEffect._instance.endFade));

        yield return(new WaitForSeconds(.25f));

        SceneUtils.ToSelectionScene();
    }
예제 #24
0
        private void CreateSpawn(int spawnNumber, GameObject playerSpawnGo, List <GameObject> unitSpawnPoints)
        {
            Vector3 randomLanceSpawn = unitSpawnPoints.GetRandom().transform.localPosition;
            Vector3 spawnPositon     = SceneUtils.GetRandomPositionFromTarget(randomLanceSpawn, 24, 100);

            spawnPositon = spawnPositon.GetClosestHexLerpedPointOnGrid();

            int failSafe = 0;

            while (spawnPositon.IsTooCloseToAnotherSpawn())
            {
                spawnPositon = SceneUtils.GetRandomPositionFromTarget(randomLanceSpawn, 24, 100);
                spawnPositon = spawnPositon.GetClosestHexLerpedPointOnGrid();
                if (failSafe > 20)
                {
                    break;
                }
                failSafe++;
            }

            Main.Logger.Log($"[AddCustomPlayerLanceExtraSpawnPoints] Creating lance 'Player Lance' spawn point 'UnitSpawnPoint{spawnNumber}'");
            LanceSpawnerFactory.CreateUnitSpawnPoint(playerSpawnGo, $"UnitSpawnPoint{spawnNumber}", spawnPositon, Guid.NewGuid().ToString());
        }
예제 #25
0
    private void GenerateRandomSpinnerTexts()
    {
        int           num  = 1;
        List <string> list = new List <string>();

        while (true)
        {
            string item = GameStrings.Get("GLUE_SPINNER_" + num);
            if (item == ("GLUE_SPINNER_" + num))
            {
                break;
            }
            list.Add(item);
            num++;
        }
        SceneUtils.FindChild(base.gameObject, "NAME_PerfectOpponent").gameObject.GetComponent <UberText>().Text = GameStrings.Get("GLUE_MATCHMAKER_PERFECT_OPPONENT");
        for (num = 0; num < 10; num++)
        {
            int index = Mathf.FloorToInt(UnityEngine.Random.value * list.Count);
            this.m_spinnerTexts[num].GetComponent <UberText>().Text = list[index];
            list.RemoveAt(index);
        }
    }
예제 #26
0
    protected virtual void Awake()
    {
        s_instance = this;
        CollectionManager.Get().RegisterAchievesCompletedListener(new CollectionManager.DelOnAchievesCompleted(this.OnCollectionAchievesCompleted));
        AchieveManager.Get().TriggerLaunchDayEvent();
        AchieveManager.Get().UpdateActiveAchieves(new AchieveManager.ActiveAchievesUpdatedCallback(this.OnAchievesUpdated));
        this.m_hitbox.gameObject.SetActive(false);
        string key = "GLOBAL_CLICK_TO_CONTINUE";

        if (UniversalInputManager.Get().IsTouchMode())
        {
            key = "GLOBAL_CLICK_TO_CONTINUE_TOUCH";
        }
        this.m_continueText.Text = GameStrings.Get(key);
        this.m_continueText.gameObject.SetActive(false);
        PegUI.Get().SetInputCamera(CameraUtils.FindFirstByLayer(GameLayer.IgnoreFullScreenEffects));
        SceneUtils.SetLayer(this.m_hitbox.gameObject, GameLayer.IgnoreFullScreenEffects);
        SceneUtils.SetLayer(this.m_continueText.gameObject, GameLayer.IgnoreFullScreenEffects);
        if (!Network.ShouldBeConnectedToAurora())
        {
            this.UpdateRewards();
        }
    }
 private void LoadActorCallback(string actorName, GameObject actorObject, object callbackData)
 {
     if (actorObject == null)
     {
         Debug.LogWarning(string.Format("HistoryChildCard.LoadActorCallback() - FAILED to load actor \"{0}\"", actorName));
     }
     else
     {
         Actor component = actorObject.GetComponent <Actor>();
         if (component == null)
         {
             Debug.LogWarning(string.Format("HistoryChildCard.LoadActorCallback() - ERROR actor \"{0}\" has no Actor component", actorName));
         }
         else
         {
             base.m_mainCardActor = component;
             base.m_mainCardActor.SetCardFlair(base.m_entity.GetCardFlair());
             base.m_mainCardActor.SetHistoryChildCard(this);
             base.m_mainCardActor.UpdateAllComponents();
             SceneUtils.SetLayer(base.m_mainCardActor.gameObject, GameLayer.Tooltip);
             base.m_mainCardActor.Hide();
         }
     }
 }
예제 #28
0
    public void init(TargetOptions options, MovementDirection direction, int path)
    {
        const float widthShift     = 0.5f;
        var         spriteRenderer = GetComponent <SpriteRenderer>();

        speed = options.speed;

        var sprites = Resources.LoadAll <Sprite>(options.path);

        spriteRenderer.sprite = sprites[options.spriteNumber];
        if (direction == MovementDirection.left)
        {
            spriteRenderer.flipX = true;
        }

        var boxCollider2D = GetComponent <BoxCollider2D>();

        boxCollider2D.size = spriteRenderer.size;

        SceneUtils  scene     = SceneUtils.instance;
        const float startPath = -1;
        var         y         = startPath + path;
        var         x         = 0f;

        if (direction == MovementDirection.left)
        {
            x = scene.maxX + widthShift;
        }
        else
        {
            x = scene.minX - widthShift;
        }
        transform.position = new Vector3(x, y, 0);

        movementDirection = direction;
    }
예제 #29
0
        public override void Trigger(MessageCenterMessage inMessage, string triggeringName)
        {
            Main.LogDebug("[PositionRegion] Positioning Region...");
            GameObject      regionGo    = GameObject.Find(RegionName);
            CombatGameState combatState = UnityGameInstance.BattleTechGame.Combat;
            Team            playerTeam  = combatState.LocalPlayerTeam;

            Vector3       centerOfTeamMass = GetCenterOfTeamMass(playerTeam, true);
            Vector3       possiblePosition = Vector3.zero;
            AbstractActor actor            = combatState.AllActors.First((AbstractActor x) => x.TeamId == playerTeam.GUID);

            while (possiblePosition == Vector3.zero || !PathFinderManager.Instance.IsSpawnValid(regionGo, possiblePosition, actor.GameRep.transform.position, UnitType.Mech, $"PositionRegionResult.{RegionName}"))
            {
                Main.LogDebug($"[PositionRegion] {(possiblePosition == Vector3.zero ? "Finding possible position..." : "Trying again to find a possible position...")}");
                possiblePosition = SceneUtils.GetRandomPositionFromTarget(centerOfTeamMass, Main.Settings.DynamicWithdraw.MinDistanceForZone, Main.Settings.DynamicWithdraw.MaxDistanceForZone);
            }
            regionGo.transform.position = possiblePosition;

            // Debug
            // GameObjextExtensions.CreateDebugPoint("DEBUGCenterofTeamMassGizmo", centerOfTeamMass, Color.red);
            // GameObjextExtensions.CreateDebugPoint("DEBUGDynamicWithdrawCenter", regionGo.transform.position, Color.blue);

            RegenerateRegion(regionGo);
        }
    private void Start()
    {
        Actor actor = SceneUtils.FindComponentInThisOrParents <Actor>(base.gameObject);

        if (actor == null)
        {
            Spell message = SceneUtils.FindComponentInParents <Spell>(base.gameObject);
            if (message != null)
            {
                Debug.Log(message);
                Debug.Log(message.GetSourceCard());
                actor = message.GetSourceCard().GetActor();
            }
        }
        if (actor == null)
        {
            Debug.LogError(string.Format("SnapActorToGameObject on {0} failed to find Actor object!", base.gameObject.name));
            base.enabled = false;
        }
        else
        {
            this.m_actorTransform = actor.transform;
        }
    }