コード例 #1
0
        private static void Postfix(ActorMenu __instance)
        {
            if (!Main.enabled)
            {
                return;
            }

            try
            {
                CharId     newTaiwuId = DateFile.instance.MianActorID();
                Succession succession;
                if (taiwuOpinionsOfPredecessor.TryGetValue(newTaiwuId, out succession))
                {
                    var predecessor = DateFile.instance.actorsDate[succession.predecessor];

                    // 恢复前后两代太吾的关系值
                    predecessor[CharDataIndex.OPINION] = succession.opinion.ToString();

                    // 标记前代为死亡太吾
                    DeadTaiwuManager.instance.setAsDeadTaiwu(succession.predecessor);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
コード例 #2
0
        public void clearDeadTaiwu(CharId charId)
        {
            deadTaiwuList.Remove(charId);

            // 因为初始化的时候只扫坟里的,投胎也只投坟里的,所以就算不清除标记也不会导致重复投胎
            // DateFile.instance.actorsDate[charId][CharDataIndex.LOVE] = "0";
        }
コード例 #3
0
        private static void Postfix(ActorMenu __instance)
        {
            if (!Main.enabled)
            {
                return;
            }

            try
            {
                CharId     newTaiwuId = DateFile.instance.MianActorID();
                Succession succession;
                if (taiwuOpinionsOfPredecessor.TryGetValue(newTaiwuId, out succession))
                {
                    var predecessor = DateFile.instance.actorsDate[succession.predecessor];

                    // 恢复前后两代太吾的关系值
                    predecessor[CharDataIndex.OPINION] = succession.opinion.ToString();

                    // 标记前代为死亡太吾
                    if (Main.settings.lockFaceTaiwu)
                    {
                        predecessor[CharDataIndex.MOOD] = MagicNum.DEAD_TAIWU_MOOD.ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
コード例 #4
0
    public void LaunchVictoryAnimation(CharId winnerCharId)
    {
        // stop music
        GameObject.FindGameObjectWithTag("Music")?.SetActive(false);

        // setup delayed tasks
        float cachedAnimationDuration = SpecialTitleAnimationDuration;

        // play ad
        (this).ExecuteAfterTime(cachedAnimationDuration + VICTORY_SCREEN_DURATION, () =>
        {
            ShowAdThenShowScene();
        });

        // start timer
        this.ExecuteAfterTime(cachedAnimationDuration, () =>
        {
            _timerRemainingTime.StartTimer(VICTORY_SCREEN_DURATION);
        });

        // update canvas activation
        DeactivateGamePanel();
        _victoryCanvas.SetActive(true);

        OnLaunchVictoryAnimation?.Invoke(VICTORY_SCREEN_DURATION);

        CameraEffectController.Instance.EnableBlur(true);

        // update content
        SetWinnerContent(winnerCharId);
        SetSpecialPlayersContent(winnerCharId); // we put it at the end of method, if it has errors
    }
コード例 #5
0
 public override void DumpBody(XmlWriter writer)
 {
     if (SwfDumpService.DumpDisplayListTags)
     {
         writer.WriteElementString("cid", CharId.ToString());
         writer.WriteElementString("depth", Depth.ToString());
     }
 }
コード例 #6
0
ファイル: SamsaraLock.cs プロジェクト: zzBruce/Taiwu_mods
 // 把charId对应人物标记为死太吾,并且放进Cache
 public void setAsDeadTaiwu(CharId charId)
 {
     GameData.Characters.SetCharProperty(charId, CharDataIndex.LOVE, DEAD_TAIWU_LOVE.ToString());
     if (!deadTaiwuList.Contains(charId))
     {
         deadTaiwuList.Add(charId);
     }
 }
コード例 #7
0
ファイル: SamsaraLock.cs プロジェクト: zy9634/Taiwu_mods
 // 把charId对应人物标记为死太吾,并且放进Cache
 public void setAsDeadTaiwu(CharId charId)
 {
     DateFile.instance.actorsDate[charId][CharDataIndex.LOVE] = DEAD_TAIWU_LOVE.ToString();
     if (!deadTaiwuList.Contains(charId))
     {
         deadTaiwuList.Add(charId);
     }
 }
コード例 #8
0
    void OnCharacterKill(CharId killedCharacter)
    {
        int killAmount = GameManager.Instance.Gamemode.KillCount;

        if (_killAmountToSpawnPickup >= killAmount)
        {
            SpawnProjectilePickup();
        }
    }
コード例 #9
0
    public CharacterStatistics(CharId charId, CharController characterController)
    {
        _charId = charId;
        _characterController = characterController;

        _characterController.OnJump      += OnJump;
        _characterController.OnAttack    += OnAttack;
        _characterController.OnAttackHit += OnAttackHit;
        _characterController.OnProjectilePickupPicked           += OnProjectilePickupPicked;
        _characterController.GetComponent <Entity>().OnKillMade += OnKillMade;
    }
コード例 #10
0
    public static string GetSpriteHex(this CharId playerId)
    {
        float goldenRatio = (int)playerId * 0.618033988749895f;

        float r = goldenRatio % 1f;
        float g = 0.5f;
        float b = Mathf.Sqrt(1f - goldenRatio % 0.5f);

        //return Color.HSVToRGB(0.1f * (int)playerId, 0.5f, 1.0f).ToHex();
        return(Color.HSVToRGB(r, g, b).ToHex());
    }
コード例 #11
0
        public override int GetHashCode()
        {
            var hash = base.GetHashCode();

            hash ^= Readonly.GetHashCode();
            hash ^= IntId.GetHashCode();
            hash ^= UIntId.GetHashCode();
            hash ^= LongId.GetHashCode();
            hash ^= ULongId.GetHashCode();
            hash ^= ShortId.GetHashCode();
            hash ^= UShortId.GetHashCode();
            hash ^= DoulbeId.GetHashCode();
            hash ^= ByteId.GetHashCode();
            hash ^= CharId.GetHashCode();
            hash ^= SByteId.GetHashCode();
            hash ^= CharRef.GetHashCode();
            hash ^= ByteRef.GetHashCode();
            hash ^= SByteRef.GetHashCode();
            hash ^= Int16Id.GetHashCode();
            hash ^= UInt16Id.GetHashCode();
            hash ^= Int32Id.GetHashCode();
            hash ^= UInt32Id.GetHashCode();
            hash ^= Int64Id.GetHashCode();
            hash ^= UInt64Id.GetHashCode();
            hash ^= DateTime.GetHashCode();
            hash ^= TitleEnum.GetHashCode();
            hash ^= ATitleEnum.GetHashCode();
            hash ^= FirstName.GetHashCode();
            hash ^= LastName.GetHashCode();
            hash ^= Bool.GetHashCode();
            hash ^= BoolRef.GetHashCode();
            if (Array != null)
            {
                hash ^= Array.GetHashCode();
            }
            if (Enumerable != null)
            {
                hash ^= Enumerable.GetHashCode();
            }
            if (Father != null)
            {
                hash ^= Father.GetHashCode();
            }
            if (Mother != null)
            {
                hash ^= Mother.GetHashCode();
            }
            if (Hidden != null)
            {
                hash ^= Hidden.GetHashCode();
            }
            return(hash);
        }
コード例 #12
0
    void SetWinnerContent(CharId winnerCharId)
    {
        Color winnerUIColor = winnerCharId.GetUIColor();

        // update nickname
        _winnerNickname.text = CharIdAllocator.GetNickname(winnerCharId);
        //_winnerNickname.color = winnerUIColor;

        // update profile picture
        _winnerProfilePictureOutline.color = winnerUIColor;
        ProfilePictureManager.Instance.SetProfilePicture(winnerCharId, _winnerProfilePicture);
    }
コード例 #13
0
 public override void DumpBody(XmlWriter writer)
 {
     if (SwfDumpService.DumpDisplayListTags)
     {
         writer.WriteElementString("cid", CharId.ToString());
         writer.WriteElementString("depth", Depth.ToString());
         writer.WriteElementString("matrix", Matrix.GetMatrixString());
         if (ColorTransform != null)
         {
             ColorTransform.Dump(writer, false);
         }
     }
 }
コード例 #14
0
    static CharId GetNextCharID()
    {
        Debug.LogFormat("charId = {0}", charId);

        if (charId == CharId.Purple)
        {
            charId = CharId.Red;
        }
        else
        {
            charId = (CharId)charId + 1;
            Debug.LogFormat("CharId ++; {0}", charId);
        }

        return(charId);
    }
コード例 #15
0
 public void Dump(XmlWriter writer, SwfTagCode tagCode)
 {
     writer.WriteStartElement("button");
     writer.WriteAttributeString("id", CharId.ToString());
     writer.WriteAttributeString("depth", PlaceDepth.ToString());
     writer.WriteElementString("matrix", PlaceMatrix.GetMatrixString());
     ColorTransform.Dump(writer, HasAlpha(tagCode));
     if (_filters.Count > 0)
     {
         _filters.Dump(writer);
     }
     if ((State & SwfButtonState.HasBlendMode) != 0)
     {
         writer.WriteElementString("blend-mode", BlendMode.ToString());
     }
     writer.WriteEndElement();
 }
コード例 #16
0
        public static bool triggerDreamEvent(CharId childId, CharId taiwuCharId)
        {
            if (DateFile.instance.GetActorFavor(false, DateFile.instance.MianActorID(), taiwuCharId, false, false) >= 30000)
            {
                int gangGroup = int.Parse(DateFile.instance.GetActorDate(childId, 19, false));
                UIDate.instance.changTrunEvents.Add(new int[]
                {
                    239,
                    taiwuCharId,
                    int.Parse(DateFile.instance.GetGangDate(gangGroup, 3))
                });

                return(true);
            }

            return(false);
        }
コード例 #17
0
    public static string GetUIHex(this CharId playerId)
    {
        switch (playerId)
        {
        case CharId.Red:
            return("CF4436");

        case CharId.Blue:
            return("2E87C2");

        case CharId.Green:
            return("28B263");

        case CharId.Purple:
            return("844C9C");
        }

        return("ffffff");
    }
コード例 #18
0
    public static CharControls ToControls(this CharId playerId)
    {
        switch (playerId)
        {
        case CharId.Red:
            return(new CharControls(KeyCode.LeftArrow, KeyCode.RightArrow, KeyCode.UpArrow, KeyCode.DownArrow, KeyCode.Keypad0));

        case CharId.Blue:
            return(new CharControls(KeyCode.Q, KeyCode.D, KeyCode.Z, KeyCode.S, KeyCode.E));

        case CharId.Green:
            return(new CharControls(KeyCode.K, KeyCode.M, KeyCode.O, KeyCode.L, KeyCode.P));

        case CharId.Purple:
            return(new CharControls(KeyCode.Keypad4, KeyCode.Keypad6, KeyCode.Keypad8, KeyCode.Keypad5, KeyCode.Keypad9));
        }

        return(new CharControls(KeyCode.Alpha0, KeyCode.Alpha1, KeyCode.Alpha2, KeyCode.Alpha3, KeyCode.Alpha4));
    }
コード例 #19
0
    public override void Kill(CharId?killerCharID, CharId victim)
    {
        // update score
        if (killerCharID != null)
        {
            CharId c_killerCharID = (CharId)killerCharID;
            _charactersValue[c_killerCharID]++;

            OnScoreUpdate?.Invoke(CharactersValueArray, valueForVictory);
        }

        EventController.Instance.OnKill();
        CameraShake.Instance.Shake();

        CheckForNewMVP(killerCharID);
        CheckForVictory();

        // at the end, because it trigger an event
        base.Kill(killerCharID, victim);
    }
コード例 #20
0
    void SetSpecialPlayersContent(CharId winnerCharId)
    {
        var charIdsOrderByScore = GameManager.Instance.Gamemode.GetCharIdsOrderByScore();

        Assert.AreEqual(_specialPlayerWrappers.Length, Enum.GetValues(typeof(CharId)).Length - 1, "Special players wrapper should have " + (Enum.GetValues(typeof(CharId)).Length - 1) + " elements!");

        var characterStatistics            = FindObjectOfType <StatisticsManager>().CharacterStatistics;
        Dictionary <CharId, string> titles = GetSpecialTitle(winnerCharId, characterStatistics);

        for (int i = 0; i < _specialPlayerWrappers.Length; i++)
        {
            var wrapper = _specialPlayerWrappers[i];
            var charId  = charIdsOrderByScore[i + 1]; // we add 1 to skip the winner

            // if player is not connected
            if (!CharIdAllocator.IsCharIdConnected(charId))
            {
                // disable wrapper
                wrapper.gameObject.SetActive(false);
                continue;
            }

            wrapper.gameObject.SetActive(false);

            // content
            wrapper.UpdateCharIdContent(charId);
            wrapper.SpecialTitle.text = titles[charId];

            // animation
            float animationDelay = i * DELAY_BETWEEN_ANIMATION + i * ANIMATION_DURATION;

            this.ExecuteAfterTime(animationDelay, () => wrapper.gameObject.SetActive(true));

            wrapper.transform.localScale = Vector3.one * 1.4f;
            wrapper.transform.DOScale(Vector3.one, ANIMATION_DURATION)
            .SetEase(Ease.InQuint)
            .SetDelay(animationDelay)
            .OnComplete(() => CameraShake.Instance.Shake(0.1f, 0.05f));
        }
    }
コード例 #21
0
    Dictionary <CharId, string> GetSpecialTitle(CharId winnerId, Dictionary <CharId, CharacterStatistics> characterStatistics)
    {
        Dictionary <CharId, string> specialTitles = new Dictionary <CharId, string>();

        characterStatistics.Remove(winnerId);

        CheckSpecialTitle(ref characterStatistics, ref specialTitles, "_virusReleased", 1, "Hacker");
        CheckSpecialTitle(ref characterStatistics, ref specialTitles, "_tackleSumDamage", 80, "Scrapper");
        CheckSpecialTitle(ref characterStatistics, ref specialTitles, "_projectileThrowCount", 4, "Crazy Shooter");
        CheckSpecialTitle(ref characterStatistics, ref specialTitles, "_jumpCount", 0, "Climber");

        // fill empty title by a random title
        foreach (var charId in (CharId[])Enum.GetValues(typeof(CharId)))
        {
            if (!specialTitles.ContainsKey(charId))
            {
                specialTitles.Add(charId, "Collector");
            }
        }

        return(specialTitles);
    }
コード例 #22
0
        private static void Prefix(ActorMenu __instance)
        {
            if (!Main.enabled)
            {
                return;
            }

            try
            {
                CharId oldTaiwuId = DateFile.instance.MianActorID();
                CharId newTaiwuId = (int)typeof(ActorMenu).GetField("chooseNewActor", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);

                // 保存前后两代太吾的关系值
                var succession = new Succession();
                succession.predecessor = oldTaiwuId;
                succession.opinion     = DateFile.instance.GetActorFavor(false, oldTaiwuId, newTaiwuId, false, false);
                taiwuOpinionsOfPredecessor.Add(newTaiwuId, succession);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
コード例 #23
0
    void CheckSpecialTitle(ref Dictionary <CharId, CharacterStatistics> characterStatistics, ref Dictionary <CharId, string> specialTitles, string fieldToCompare, int condition, string title)
    {
        FieldInfo field = typeof(CharacterStatistics).GetField(fieldToCompare, BindingFlags.NonPublic | BindingFlags.Instance);

        var firstOfSpecialTitle = characterStatistics
                                  .Select(x => x.Value)
                                  .Where(x => (int)field.GetValue(x) >= condition) // achieve condition
                                  .OrderBy(x => (int)field.GetValue(x))            // the first, the better
                                  .FirstOrDefault();

        // is there is someone that achieve condition ?
        if (firstOfSpecialTitle != null)
        {
            // get charId of first of special title
            CharId charId = characterStatistics.FirstOrDefault(x => x.Value == firstOfSpecialTitle).Key;

            if (!specialTitles.ContainsKey(charId))
            {
                // set title to the first of special title
                specialTitles.Add(charId, title);
            }
        }
    }
コード例 #24
0
 protected override void Victory(CharId winnerCharId)
 {
     UIVictoryManager.Instance.LaunchVictoryAnimation(winnerCharId);
 }
コード例 #25
0
        // 判定是否要进行强制太吾降生,如果要进行的话,从坟场里拿出一个太吾ID进行强制降生
        // return: whether it is a taiwu getting delivered after the function applied any possible modification.
        public bool tryDeadTaiwuBirthPreemption(int childId, ref List <CharId> previousLives)
        {
            // 判定太吾是否要抢这次降生机会
            if (Main.settings.taiwuPreemptRate <= 0 ||
                deadTaiwuList.Count == 0 ||
                UnityEngine.Random.Range(0, 100) >= Main.settings.taiwuPreemptRate)
            {
                return(false);
            }

            if (previousLives == null || previousLives.Count == 0)
            {
                if (deadTaiwuList.Count != 0)
                {
                    Console.WriteLine("Error: Martian dead taiwu in registry. Registry cleared.");
                    deadTaiwuList.Clear();
                }
                return(false);
            }

            // 检查正在降生的是否已经是死太吾
            CharId preemptedCharId = previousLives[previousLives.Count - 1];

            if (deadTaiwuList.Contains(preemptedCharId))
            {
                clearDeadTaiwu(preemptedCharId);
                if (!isDeadTaiwu(preemptedCharId))
                {
                    Console.WriteLine("Error: fake taiwu in registry");
                    return(false);
                }
                return(true);
            }

            Console.WriteLine("Start preempting birth for taiwu.");
            Main.Logger.Log("Start preempting birth for taiwu.");

            var livesBackup = new List <CharId>(previousLives);

            try
            {
                DateFile data = DateFile.instance;

                // 选取一只太吾
                CharId taiwuCharId = deadTaiwuList[0];
                clearDeadTaiwu(taiwuCharId);

                // Due diligence
                if (!isDeadTaiwu(taiwuCharId))
                {
                    Console.WriteLine("Error: fake taiwu in registry");
                    return(false);
                }

                // 从坟里挖出来
                if (!data.deadActors.Remove(taiwuCharId))
                {
                    Console.WriteLine("Error: trying to reincarnation character not in grave.");
                    return(false);
                }

                // 塞进轮回
                previousLives.Clear();
                previousLives.AddRange(new List <int>(data.GetLifeDateList(taiwuCharId, 801, false))
                {
                    taiwuCharId
                });

                // 把被抢占的人塞回坟墓
                data.deadActors.Add(preemptedCharId);

                // 触发托梦事件
                triggerDreamEvent(childId, taiwuCharId);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                Console.WriteLine("Error: Failed birth preempting attempt.");

                // 恢复原本轮回数据
                previousLives = livesBackup;

                return(false);
            }

            return(true);
        }
コード例 #26
0
    public void SetProfilePicture(CharId charId, Image destination)
    {
        int deviceId = CharIdAllocator.GetDeviceId(charId);

        SetProfilePicture(deviceId, destination);
    }
コード例 #27
0
 public static Color GetSpriteColor(this CharId playerId)
 {
     return(playerId.GetSpriteHex().HexToColor());
 }
コード例 #28
0
 public static bool isDeadTaiwu(CharId charId)
 {
     return(DateFile.instance.GetActorDate(charId, CharDataIndex.LOVE, false) == DEAD_TAIWU_LOVE.ToString());
 }
コード例 #29
0
 // 把charId对应人物标记为死太吾,并且放进Cache
 public void setAsDeadTaiwu(CharId charId)
 {
     DateFile.instance.actorsDate[charId][CharDataIndex.MOOD] = DEAD_TAIWU_MOOD.ToString();
     deadTaiwuList.Add(charId);
 }