Ejemplo n.º 1
0
    /// <summary>
    /// Creation of a JoyObject (MonoBehaviour) using a List of Sprites
    /// </summary>
    /// <param name="name"></param>
    /// <param name="hitPoints"></param>
    /// <param name="position"></param>
    /// <param name="sprites"></param>
    /// <param name="baseType"></param>
    /// <param name="isAnimated"></param>
    /// <param name="isWall"></param>
    public JoyObject(string name, int hitPoints, Vector2Int position, List <Sprite> sprites, string baseType, bool isAnimated, bool isWall = false, bool isDestructible = true)
    {
        this.JoyName = name;
        this.GUID    = GUIDManager.AssignGUID();

        this.m_HitPoints = hitPoints;

        this.m_WorldPosition = position;
        this.Move(this.m_WorldPosition);

        this.m_Icons = sprites.ToArray();

        this.BaseType       = baseType;
        this.IsAnimated     = isAnimated;
        this.IsWall         = isWall;
        this.IsDestructible = isDestructible;

        //If it's not animated, select a random icon to represent it
        if (!this.IsAnimated && sprites != null)
        {
            this.ChosenIcon = RNG.Roll(0, sprites.Count - 1);
        }
        else
        {
            this.ChosenIcon = 0;
        }

        this.m_LastIcon = 0;
        this.m_FramesSinceLastChange = 0;
    }
Ejemplo n.º 2
0
 public EntityFactory(
     GUIDManager guidManager,
     INeedHandler needHandler,
     IObjectIconHandler objectIconHandler,
     ICultureHandler cultureHandler,
     IEntitySexualityHandler sexualityHandler,
     IEntityBioSexHandler sexHandler,
     IGenderHandler genderHandler,
     IEntityRomanceHandler romanceHandler,
     IJobHandler jobHandler,
     IPhysicsManager physicsManager,
     IEntitySkillHandler skillHandler,
     IDerivedValueHandler derivedValueHandler,
     RNG roller)
 {
     this.GuidManager         = guidManager;
     this.Roller              = roller;
     this.NeedHandler         = needHandler;
     this.ObjectIcons         = objectIconHandler;
     this.CultureHandler      = cultureHandler;
     this.SexualityHandler    = sexualityHandler;
     this.BioSexHandler       = sexHandler;
     this.JobHandler          = jobHandler;
     this.RomanceHandler      = romanceHandler;
     this.GenderHandler       = genderHandler;
     this.PhysicsManager      = physicsManager;
     this.SkillHandler        = skillHandler;
     this.DerivedValueHandler = derivedValueHandler;
 }
Ejemplo n.º 3
0
 public void ActivateStateFromParam(State startState)
 {
     if (GUIDManager.GetChainByStateGuid(startState.stateGUID).returnAfterEnd)
     {
         Debug.Log("push " + currentState.description);
         brokenStates.Push(currentState);
     }
     ActivateState(startState);
 }
Ejemplo n.º 4
0
    public static GUIDManager GetInstance()
    {
        if (_instance == null)
        {
            _instance = new GUIDManager();
        }

        return(_instance);
    }
Ejemplo n.º 5
0
 public DungeonInteriorGenerator(
     GUIDManager guidManager,
     IObjectIconHandler objectIconHandler,
     IDerivedValueHandler derivedValueHandler,
     IWorldInfoHandler worldInfoHandler,
     RNG roller)
 {
     this.GuidManager         = guidManager;
     this.DerivedValueHandler = derivedValueHandler;
     this.Roller           = roller;
     this.WorldInfoHandler = worldInfoHandler;
     this.ObjectIcons      = objectIconHandler;
 }
Ejemplo n.º 6
0
        public ItemInstance(ItemInstance item) :
            base(item.ItemType.UnidentifiedName, item.ItemType.GetHitPoints(), item.WorldPosition, item.Icons, item.BaseType, item.IsAnimated, false, false)
        {
            this.m_Type = item.ItemType;
            this.Move(item.WorldPosition);

            this.m_HitPoints          = item.ItemType.GetHitPoints();
            this.m_HitPointsRemaining = this.m_HitPoints;
            this.GUID       = GUIDManager.AssignGUID();
            this.Identified = item.Identified;

            this.m_Contents = item.m_Contents;

            m_InteractionFile = item.m_InteractionFile;
        }
Ejemplo n.º 7
0
        public ItemInstance(BaseItemType type, Vector2Int position, bool identified, string interactionFile = null) :
            base(type.UnidentifiedName, type.GetHitPoints(), position, ObjectIcons.GetSprites(type.Category, type.UnidentifiedName), type.Category, false)
        {
            this.m_Type = type;
            this.Move(position);

            this.m_HitPoints          = type.GetHitPoints();
            this.m_HitPointsRemaining = this.m_HitPoints;
            this.GUID       = GUIDManager.AssignGUID();
            this.Identified = identified;
            //chosenIcon = RNG.Roll(0, m_Icons.Length - 1);

            this.m_Contents = new List <long>();

            m_InteractionFile = interactionFile;
        }
Ejemplo n.º 8
0
 public ItemFactory(
     GUIDManager guidManager,
     IItemDatabase itemDatabase,
     ILiveItemHandler itemHandler,
     IObjectIconHandler objectIconHandler,
     IDerivedValueHandler derivedValueHandler,
     GameObjectPool <JoyObjectNode> itemPool,
     RNG roller = null)
 {
     this.GuidManager         = guidManager;
     this.ItemDatabase        = itemDatabase;
     this.ItemHandler         = itemHandler;
     this.ObjectIcons         = objectIconHandler;
     this.DerivedValueHandler = derivedValueHandler;
     this.ItemPool            = itemPool;
     this.Roller = roller is null ? new RNG() : roller;
 }
Ejemplo n.º 9
0
    private void Play(PathGame pathGame)
    {
        this.pathGame = pathGame;
        if (pathGame)
        {
            GUIDManager.SetInspectedGame(pathGame);
            PilePlayer pp = gameObject.AddComponent <PilePlayer>();
            pp.Init(shufflePileAfterEnd);
            ChainPlayer     cp = gameObject.AddComponent <ChainPlayer>();
            ResourceManager rm = gameObject.AddComponent <ResourceManager>();
            if (visualizer)
            {
                visualizer.Init(rm);
            }

            rm.Init(pathGame);
            InputListener il = gameObject.AddComponent <InputListener>();

            if (initWithPacks)
            {
                foreach (ChainPack chainPack in pathGame.chainPacks)
                {
                    if (chainPack.tags == "")
                    {
                        pp.Add(chainPack);
                    }
                    else
                    {
                        foreach (string s in chainPack.tags.Split(','))
                        {
                            if (packsTags.Contains(s))
                            {
                                pp.Add(chainPack);
                            }
                        }
                    }
                }
                pp.Shuffle();
                GUIDManager.SetInspectedGame(pathGame);
                FindObjectOfType <ChainPlayer>().PlayChain(pp.GetChain());
                GUIDManager.SetInspectedGame(pathGame);
            }
        }
    }
Ejemplo n.º 10
0
        /// <summary>
        /// For creating a well-established WorldInstance
        /// </summary>
        /// <param name="tiles"></param>
        /// <param name="areas"></param>
        /// <param name="entities"></param>
        /// <param name="objects"></param>
        /// <param name="type"></param>
        /// <param name="name"></param>
        public WorldInstance(WorldTile[,] tiles, Dictionary <Vector2Int, WorldInstance> areas, List <Entity> entities,
                             List <JoyObject> objects, Dictionary <Vector2Int, JoyObject> walls, WorldType type, string name)
        {
            this.Name    = name;
            this.m_Type  = type;
            m_Tiles      = tiles;
            m_Areas      = areas;
            m_Entities   = entities;
            m_Objects    = objects;
            m_Walls      = walls;
            GUID         = GUIDManager.AssignGUID();
            m_Discovered = new bool[m_Tiles.GetLength(0), m_Tiles.GetLength(1)];
            CalculatePlayerIndex();
            m_Light = new int[m_Tiles.GetLength(0), m_Tiles.GetLength(1)];

            m_FogOfWarHolder = GameObject.Find("WorldFog");
            m_WallHolder     = GameObject.Find("WorldWalls");
            m_ObjectHolder   = GameObject.Find("WorldObjects");
            m_EntityHolder   = GameObject.Find("WorldEntities");
        }
Ejemplo n.º 11
0
        /// <summary>
        /// A template for adding stuff to later. A blank WorldInstance.
        /// </summary>
        /// <param name="tiles"></param>
        /// <param name="type"></param>
        /// <param name="name"></param>
        public WorldInstance(WorldTile[,] tiles, WorldType type, string name)
        {
            m_Dimensions = new Vector2Int(tiles.GetLength(0), tiles.GetLength(1));

            this.Name    = name;
            this.m_Type  = type;
            m_Tiles      = tiles;
            m_Areas      = new Dictionary <Vector2Int, WorldInstance>();
            m_Entities   = new List <Entity>();
            m_Objects    = new List <JoyObject>();
            m_Walls      = new Dictionary <Vector2Int, JoyObject>();
            GUID         = GUIDManager.AssignGUID();
            m_Discovered = new bool[m_Tiles.GetLength(0), m_Tiles.GetLength(1)];
            m_Light      = new int[m_Tiles.GetLength(0), m_Tiles.GetLength(1)];

            m_FogOfWarHolder = GameObject.Find("WorldFog");
            m_WallHolder     = GameObject.Find("WorldWalls");
            m_ObjectHolder   = GameObject.Find("WorldObjects");
            m_EntityHolder   = GameObject.Find("WorldEntities");
        }
Ejemplo n.º 12
0
        private void OnPlayerUnlock(ObjectUnlockEvent theEvent)
        {
            Player player   = theEvent.Sender;
            var    playerId = player.Id.ToString();

            if (AllowLockPicking)
            {
                return;
            }
            if (DeclarationOfWarEnable)
            {
                var         playerguild   = player.GetGuild();
                ulong       playerguildId = playerguild.BaseID;
                CrestScheme crestScheme   = SocialAPI.Get <CrestScheme>();
                Crest       crest         = crestScheme.GetCrestAt(player.Entity.Position);
                if (crest != null)
                {
                    var   crestguid   = crest.ObjectGUID;
                    Guild targetguild = SocialAPI.Get <GuildScheme>().TryGetGuildByObject(crestguid);


                    if (IsAtWar(playerguildId, targetguild.BaseID) && targetguild != null)
                    {
                        return;
                    }
                }
            }
            if (ProtectedZoneEnable)
            {
                var zoneId   = TryGetZoneId(player);
                var zoneFlag = "lockpickingallowed";
                if (NoLockPickingInZones)
                {
                    if (!IsInZone(player))
                    {
                        return;
                    }
                }
                if (IsInZone(player) && hasFlag(zoneId.ToString(), zoneFlag))
                {
                    return;
                }
            }
            var                  name                  = "";
            var                  position              = new Vector3();
            var                  defenseLevel          = 0;
            ISecurable           securable             = GUIDManager.TryGetObject <ISecurable>(theEvent.GUID);
            Component            component             = securable as Component;
            CageCaptureManager   cageCaptureManager    = GUIDManager.TryGetObject <CageCaptureManager>(theEvent.GUID);
            PlayerCaptureManager playerCaptureManager1 = player.Entity.TryGet <PlayerCaptureManager>();

            if (playerCaptureManager1 != null && playerCaptureManager1.Captive != null && playerCaptureManager1.Captive == player.Entity && !playerCaptureManager1.Captive.Has <CageCaptureManager>())
            {
                return;                                                                                                                                                                                      //allow prisoner to escape rope with lockpick
            }
            if (cageCaptureManager)
            {
                if (AllowCageLockPicking)
                {
                    return;
                }
                if (cageCaptureManager.Prisoner != null)
                {
                    if (cageCaptureManager.PrisonerPlayerID == player.Id)
                    {
                        return;                                                  //allow prisoner to escape with lockpick
                    }
                }
                defenseLevel = securable.Defense;
            }
            else
            {
                if (AllowDoorLockPicking)
                {
                    return;
                }
                defenseLevel = securable.Defense;
            }

            if (component != null)
            {
                Entity entity = component.TryGetEntity(); //works for cages, entity is null on all doors
                position = (entity == null ? component.gameObject.transform.position : entity.Position);
                if (entity != null)
                {
                    name = Clean(entity.name);
                }
                else
                {
                    name = "Door";
                }
            }
            theEvent.Cancel(player + " tried to unlock a " + name + " at " + position);
            securable.Lock(true);
            //give lockpicks used back
            string itemname = "Lockpick";
            int amount      = defenseLevel;
            if (!ConsumeLockPicks)
            {
                GiveInventoryStack(player, itemname, amount);
            }
            if (MessageOn)
            {
                SendReply(player, Message("Warning", playerId), name);
            }

            if (LoggingOn)
            {
                Puts(Message("Log"), player, name, player.Entity.Position);
            }
        }
Ejemplo n.º 13
0
    public void ApplyChanger(PileChanger pileChanger)
    {
        switch (pileChanger.changeType)
        {
        case PileChanger.ChangeType.Shuffle:
            Shuffle();
            break;

        case PileChanger.ChangeType.Remove:
            switch (pileChanger.aim)
            {
            case PileChanger.PileChangeAim.Drop:
                if (!pileChanger.withRepeat)
                {
                    List <Chain> addingChains = GUIDManager.getChainPackByGuid(pileChanger.chainPileGUID).chains;
                    addingChains.RemoveAll(c => droped.FindAll(dc => dc.ChainGuid == c.ChainGuid).Contains(c));
                    droped.RemoveAll(c => addingChains.Contains(c));
                    ShuffleDrop();
                }
                else
                {
                    droped.RemoveAll(c => droped.FindAll(dc => dc.ChainGuid == c.ChainGuid).Contains(c));
                    ShuffleDrop();
                }
                break;

            case PileChanger.PileChangeAim.Pile:
                if (!pileChanger.withRepeat)
                {
                    List <Chain> addingChains = GUIDManager.getChainPackByGuid(pileChanger.chainPileGUID).chains;
                    addingChains.RemoveAll(c => chains.ToList().FindAll(dc => dc.ChainGuid == c.ChainGuid).Contains(c));
                    chains = new Queue <Chain>(chains.ToList().RemoveAll(c => addingChains.Contains(c)));
                    Shuffle();
                }
                else
                {
                    chains = new Queue <Chain>(chains.ToList().RemoveAll(c => chains.ToList().FindAll(dc => dc.ChainGuid == c.ChainGuid).Contains(c)));
                    ShuffleDrop();
                }
                break;

            case PileChanger.PileChangeAim.Both:
                if (!pileChanger.withRepeat)
                {
                    List <Chain> addingChains = GUIDManager.getChainPackByGuid(pileChanger.chainPileGUID).chains;
                    addingChains.RemoveAll(c => droped.FindAll(dc => dc.ChainGuid == c.ChainGuid).Contains(c));
                    addingChains.RemoveAll(c => chains.ToList().FindAll(dc => dc.ChainGuid == c.ChainGuid).Contains(c));
                    droped.RemoveAll(c => addingChains.Contains(c));
                    chains = new Queue <Chain>(chains.ToList().RemoveAll(c => addingChains.Contains(c)));
                    Shuffle();
                    ShuffleDrop();
                }
                else
                {
                    chains = new Queue <Chain>(chains.ToList().RemoveAll(c => chains.ToList().FindAll(dc => dc.ChainGuid == c.ChainGuid).Contains(c)));
                    ShuffleDrop();
                    droped.RemoveAll(c => droped.FindAll(dc => dc.ChainGuid == c.ChainGuid).Contains(c));
                    ShuffleDrop();
                }
                break;
            }
            break;

        case PileChanger.ChangeType.Add:
            switch (pileChanger.aim)
            {
            case PileChanger.PileChangeAim.Drop:
                if (!pileChanger.withRepeat)
                {
                    List <Chain> addingChains = GUIDManager.getChainPackByGuid(pileChanger.chainPileGUID).chains;
                    addingChains.RemoveAll(c => droped.FindAll(dc => dc.ChainGuid == c.ChainGuid).Contains(c));
                    droped.AddRange(addingChains);
                    ShuffleDrop();
                }
                else
                {
                    List <Chain> addingChains = GUIDManager.getChainPackByGuid(pileChanger.chainPileGUID).chains;
                    droped.AddRange(addingChains);
                    ShuffleDrop();
                }
                break;

            case PileChanger.PileChangeAim.Pile:
                if (!pileChanger.withRepeat)
                {
                    Debug.Log(GUIDManager.getChainPackByGuid(pileChanger.chainPileGUID).name);
                    List <Chain> addingChains = GUIDManager.getChainPackByGuid(pileChanger.chainPileGUID).chains;
                    Debug.Log(addingChains.Count);

                    addingChains.RemoveAll(c => chains.ToList().FindAll(dc => dc.ChainGuid == c.ChainGuid).Contains(c));

                    Debug.Log(addingChains.Count);
                    List <Chain> ch = chains.ToList();
                    ch.AddRange(addingChains);
                    chains = new Queue <Chain>(ch);
                    Shuffle();
                }
                else
                {
                    List <Chain> addingChains = GUIDManager.getChainPackByGuid(pileChanger.chainPileGUID).chains;
                    List <Chain> ch           = chains.ToList();
                    ch.AddRange(addingChains);
                    chains = new Queue <Chain>(ch);
                    ShuffleDrop();
                }
                break;

            case PileChanger.PileChangeAim.Both:
                if (!pileChanger.withRepeat)
                {
                    List <Chain> addingChains = GUIDManager.getChainPackByGuid(pileChanger.chainPileGUID).chains;
                    addingChains.RemoveAll(c => droped.FindAll(dc => dc.ChainGuid == c.ChainGuid).Contains(c));
                    addingChains.RemoveAll(c => chains.ToList().FindAll(dc => dc.ChainGuid == c.ChainGuid).Contains(c));

                    int chainsNumber = Mathf.CeilToInt((addingChains.Count + chains.Count) / (chains.Count + droped.Count));
                    addingChains = new List <Chain>(addingChains.OrderBy(a => Guid.NewGuid()).ToList());

                    droped.AddRange(addingChains.GetRange(chainsNumber, addingChains.Count - chainsNumber));
                    List <Chain> ch = chains.ToList();
                    ch.AddRange(addingChains.GetRange(0, chainsNumber));
                    chains = new Queue <Chain>(ch);
                    Shuffle();
                    ShuffleDrop();
                }
                else
                {
                    List <Chain> addingChains = GUIDManager.getChainPackByGuid(pileChanger.chainPileGUID).chains;
                    int          chainsNumber = Mathf.CeilToInt((addingChains.Count + chains.Count) / (chains.Count + droped.Count));
                    addingChains = new List <Chain>(addingChains.OrderBy(a => Guid.NewGuid()).ToList());
                    List <Chain> ch = chains.ToList();
                    ch.AddRange(addingChains.GetRange(0, chainsNumber));
                    chains = new Queue <Chain>(ch);

                    droped.AddRange(addingChains.GetRange(chainsNumber, addingChains.Count - chainsNumber));
                    Shuffle();

                    ShuffleDrop();
                }
                break;
            }
            break;
        }
    }
Ejemplo n.º 14
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            guidProp  = property.FindPropertyRelative("serializedGuid");
            nameProp  = property.FindPropertyRelative("cachedName");
            sceneProp = property.FindPropertyRelative("cachedScene");

            // Using BeginProperty / EndProperty on the parent property means that
            // prefab override logic works on the entire property.
            EditorGUI.BeginProperty(position, label, property);

            position.height = EditorGUIUtility.singleLineHeight;

            // Draw prefix label, returning the new rect we can draw in
            var guidCompPosition = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);

            System.Guid currentGuid;
            GameObject  currentGO = null;

            // working with array properties is a bit unwieldy
            // you have to get the property at each index manually
            byte[] byteArray = new byte[16];
            int    arraySize = guidProp.arraySize;

            for (int i = 0; i < arraySize; ++i)
            {
                var byteProp = guidProp.GetArrayElementAtIndex(i);
                byteArray[i] = (byte)byteProp.intValue;
            }

            currentGuid = new System.Guid(byteArray);
            currentGO   = GUIDManager.ResolveGuid(currentGuid);
            GUIDEntity currentGuidComponent = currentGO != null?currentGO.GetComponent <GUIDEntity>() : null;

            GUIDEntity component = null;

            if (currentGuid != System.Guid.Empty && currentGuidComponent == null)
            {
                // if our reference is set, but the target isn't loaded, we display the target and the scene it is in, and provide a way to clear the reference
                float buttonWidth = 55.0f;

                guidCompPosition.xMax -= buttonWidth;

                bool guiEnabled = GUI.enabled;
                GUI.enabled = false;
                EditorGUI.LabelField(guidCompPosition, new GUIContent(nameProp.stringValue, "Target GameObject is not currently loaded."), EditorStyles.objectField);
                GUI.enabled = guiEnabled;

                Rect clearButtonRect = new Rect(guidCompPosition);
                clearButtonRect.xMin  = guidCompPosition.xMax;
                clearButtonRect.xMax += buttonWidth;

                if (GUI.Button(clearButtonRect, clearButtonGUI, EditorStyles.miniButton))
                {
                    ClearPreviousGuid();
                }
            }
            else
            {
                // if our object is loaded, we can simply use an object field directly
                component = EditorGUI.ObjectField(guidCompPosition, currentGuidComponent, typeof(GUIDEntity), true) as GUIDEntity;
            }

            if (currentGuidComponent != null && component == null)
            {
                ClearPreviousGuid();
            }

            // if we have a valid reference, draw the scene name of the scene it lives in so users can find it
            if (component != null)
            {
                nameProp.stringValue = component.name;
                string scenePath = component.gameObject.scene.path;
                sceneProp.objectReferenceValue = AssetDatabase.LoadAssetAtPath <SceneAsset>(scenePath);

                // only update the GUID Prop if something changed. This fixes multi-edit on GUID References
                if (component != currentGuidComponent)
                {
                    byteArray = component.GetGuid().ToByteArray();
                    arraySize = guidProp.arraySize;
                    for (int i = 0; i < arraySize; ++i)
                    {
                        var byteProp = guidProp.GetArrayElementAtIndex(i);
                        byteProp.intValue = byteArray[i];
                    }
                }
            }

            EditorGUI.indentLevel++;
            position.y += EditorGUIUtility.singleLineHeight;
            bool cachedGUIState = GUI.enabled;

            GUI.enabled = false;
            EditorGUI.ObjectField(position, sceneLabel, sceneProp.objectReferenceValue, typeof(SceneAsset), false);
            GUI.enabled = cachedGUIState;
            EditorGUI.indentLevel--;

            EditorGUI.EndProperty();
        }
Ejemplo n.º 15
0
    public WorkerB()
    {
        var manager = GUIDManager.GetInstance();

        UniqueId = manager.ActiveGuid.ToString();
    }