コード例 #1
0
ファイル: AutoSaver.cs プロジェクト: caesuric/familiar-quest
 //[ClientRpc]
 public void RpcSaveCharacter(byte[] data)
 {
     //if (isLocalPlayer) {
     if (!Directory.Exists(Application.persistentDataPath + "/characters"))
     {
         Directory.CreateDirectory(Application.persistentDataPath + "/characters");
     }
     File.WriteAllBytes(Application.persistentDataPath + "/characters/" + GetComponent <PlayerSyncer>().characterName + ".character", data);
     GameLog.AddText("<color=green>Autosaved successfully.</color>");
     CmdFinishedSaving();
     //}
 }
コード例 #2
0
    public void SaveWorld()
    {
        GameLog.AddText("<color=green>Autosaved world state.</color>");
        var             saveObject = SavedWorld.ConvertFrom(gameObject);
        BinaryFormatter bf         = new BinaryFormatter();
        MemoryStream    ms         = new MemoryStream();

        bf.Serialize(ms, saveObject);
        if (!Directory.Exists(Application.persistentDataPath + "/worlds"))
        {
            Directory.CreateDirectory(Application.persistentDataPath + "/worlds");
        }
        File.WriteAllBytes(Application.persistentDataPath + "/worlds/" + worldName + ".world", ms.ToArray());
    }
コード例 #3
0
    //[ClientRpc]
    public void RpcCreateFloatingText(string str, Color color, int size, string logText)
    {
        //if (NetworkServer.active) return;
        var text      = Instantiate(floatingTextPrefab, transform.position, Quaternion.Euler(0, 0, 0));
        var billboard = text.GetComponent <Billboard>();

        billboard.mainCamera = GetComponent <Camera>();
        var floatingText = text.GetComponent <FloatingText>();

        floatingText.text  = str;
        floatingText.color = color;
        if (color == Color.magenta)
        {
            text.transform.Translate(0, -1, 0);
        }
        floatingText.size = size;
        GameLog.AddText(logText);
    }
コード例 #4
0
ファイル: AutoSaver.cs プロジェクト: caesuric/familiar-quest
    public void SaveCharacter()
    {
        if (currentlySaving)
        {
            return;
        }
        currentlySaving = true;
        var             saveObject = SavedCharacter.ConvertFrom(gameObject);
        BinaryFormatter bf         = new BinaryFormatter();
        MemoryStream    ms         = new MemoryStream();

        bf.Serialize(ms, saveObject);
        try {
            RpcSaveCharacter(ms.ToArray());
        }
        catch (Exception e) {
            GameLog.AddText("<color=red>Autosave failed!</color>");
            currentlySaving = false;
        }
    }
コード例 #5
0
    //[Command]
    public void CmdCreateFloatingTextWithPosition(string str, Color color, int size, string logText, Vector3 position)
    {
        var text      = Instantiate(floatingTextPrefab, position, Quaternion.Euler(0, 0, 0));
        var billboard = text.GetComponent <Billboard>();

        billboard.mainCamera = GetComponent <Camera>();
        var floatingText = text.GetComponent <FloatingText>();

        floatingText.text  = str;
        floatingText.color = color;
        if (color == Color.magenta)
        {
            text.transform.Translate(0, -1, 0);
        }
        else if (color == Color.cyan)
        {
            text.transform.Translate(0, -2, 0);
        }
        floatingText.size = size;
        logText           = AddColor(logText, color);
        GameLog.AddText(logText);
        //RpcCreateFloatingText(str, color, size, logText);
    }
コード例 #6
0
    public void OnDeath()
    {
        if (died)
        {
            return;
        }
        died = true;
        if (diedToPlayer)
        {
            foreach (var player in PlayerCharacter.players)
            {
                player.GetComponent <ExperienceGainer>().GainXP(GetComponent <RewardGiver>().xpValue / PlayerCharacter.players.Count);
                player.GainGold(GetComponent <RewardGiver>().goldValue / PlayerCharacter.players.Count);
                GameLog.AddText("You gain " + (GetComponent <RewardGiver>().goldValue / PlayerCharacter.players.Count).ToString() + " gold.");
            }
            if (PlayerCharacter.players.Count > 0 && killer != null)
            {
                var pc   = killer.GetComponent <PlayerCharacter>();
                var roll = RNG.Int(0, 2);
                if (pc != null)
                {
                    if (roll == 0 && GetComponent <AbilityUser>().soulGemPassive != null)
                    {
                        pc.GainSoulGem(GetComponent <AbilityUser>().soulGemPassive);
                    }
                    else if (roll == 0 && GetComponent <AbilityUser>().soulGemActives.Count > 0)
                    {
                        pc.GainSoulGem(GetComponent <AbilityUser>().soulGemActives[0]);
                    }
                    GetComponent <RewardGiver>().DropLoot(pc.GetComponent <Character>());
                }
            }
        }
        if (GetComponent <Boss>() != null)
        {
            LevelGen.instance.bossFightActive = false;
            var boss = GetComponent <Boss>();
            Instantiate(boss.exitPortal, boss.originalLocation, boss.exitPortal.transform.rotation);
        }
        GetComponent <AudioGenerator>().CreateDeathSound();
        var renderers = GetComponentsInChildren <Renderer>();

        foreach (var renderer in renderers)
        {
            foreach (var material in renderer.materials)
            {
                material.shader = shader;
                material.SetFloat("_DissolveCutoff", 0);
                material.SetFloat("_DissolveAlphaSource", 1);
                material.EnableKeyword("_DISSOLVEALPHASOURCE_CUSTOM_MAP");
                material.SetTexture("_DissolveMap1", texture);
                material.SetColor("_DissolveEdgeColor", new Color(1, 0.7f, 0, 1));
                material.SetFloat("_DissolveEdgeWidth", 0.125f);
                material.SetFloat("_DissolveEdgeShape", 1);
                material.SetFloat("_DissolveEdgeColorIntensity", 1);
                material.SetFloat("_DissolveEdgeTextureSource", 3);
                material.EnableKeyword("_DISSOLVEEDGETEXTURESOURCE_CUSTOM");
                material.SetTexture("_DissolveEdgeTexture", gradientTexture);
                material.SetFloat("_SmoothnessTextureChannel", 1);
            }
        }
        var colliders = GetComponentsInChildren <Collider>();

        foreach (var collider in colliders)
        {
            collider.enabled = false;
        }
        GetComponent <NavMeshAgent>().enabled = false;
        Destroy(GetComponent <Monster>().unitFrame);
        Destroy(gameObject, fadeOutTime);
    }