//TODO check if need to create new list for and re-add everything to current private void SetEntitiesMemento(EntityMemento EntityMemento, int i) { EntityMemento.playerID = hexGrid.cells[i].entityObj.GetComponent <Entity>().playerID; EntityMemento.type = hexGrid.cells[i].entityObj.GetComponent <Entity>().type; EntityMemento.cellIndex = hexGrid.cells[i].entityObj.GetComponent <Entity>().cellIndex; EntityMemento.uniqueID = hexGrid.cells[i].entityObj.GetComponent <Entity>().uniqueID; EntityMemento.maxhealth = hexGrid.cells[i].entityObj.GetComponent <Entity>().maxhealth; EntityMemento.maxmana = hexGrid.cells[i].entityObj.GetComponent <Entity>().maxmana; EntityMemento.attackdmg = hexGrid.cells[i].entityObj.GetComponent <Entity>().attackdmg; EntityMemento.maxattackpoint = hexGrid.cells[i].entityObj.GetComponent <Entity>().maxattackpoint; EntityMemento.maxmovementpoint = hexGrid.cells[i].entityObj.GetComponent <Entity>().maxmovementpoint; EntityMemento.range = hexGrid.cells[i].entityObj.GetComponent <Entity>().range; EntityMemento.rangedattackdmg = hexGrid.cells[i].entityObj.GetComponent <Entity>().rangedattackdmg; EntityMemento.armor = hexGrid.cells[i].entityObj.GetComponent <Entity>().armor; EntityMemento.armorpiercing = hexGrid.cells[i].entityObj.GetComponent <Entity>().armorpiercing; EntityMemento.rangedarmorpiercing = hexGrid.cells[i].entityObj.GetComponent <Entity>().rangedarmorpiercing; EntityMemento.vision = hexGrid.cells[i].entityObj.GetComponent <Entity>().vision; EntityMemento.specialActions = hexGrid.cells[i].entityObj.GetComponent <Entity>().specialActions; EntityMemento.permaEffects = hexGrid.cells[i].entityObj.GetComponent <Entity>().permaEffects; EntityMemento.tempEffects = hexGrid.cells[i].entityObj.GetComponent <Entity>().tempEffects; EntityMemento.currhealth = hexGrid.cells[i].entityObj.GetComponent <Entity>().currhealth; EntityMemento.currmana = hexGrid.cells[i].entityObj.GetComponent <Entity>().currmana; EntityMemento.currattackpoint = hexGrid.cells[i].entityObj.GetComponent <Entity>().currattackpoint; EntityMemento.currmovementpoint = hexGrid.cells[i].entityObj.GetComponent <Entity>().currmovementpoint; EntityMemento.idle = hexGrid.cells[i].entityObj.GetComponent <Entity>().idle; }
public override void Restore(EntityMemento memento, LevelEntities entities) { base.Restore(memento, entities); var triggerLuaMemento = (TriggerLuaMemento)memento; LuaScript = triggerLuaMemento.LuaScript; entities.Register(this); }
public override void Restore(EntityMemento memento, LevelEntities entities) { base.Restore(memento, entities); var spawnPointMemento = (SpawnPointMemento)memento; DayOneSpawn = spawnPointMemento.DayOneSpawn; TunnelEntrance = spawnPointMemento.TunnelEntrance; entities.Register(this); }
//Every Memento have to create new since current game is static public void SetMemento() { gameID = "ttt"; //TODO allow player to set gameID GameMemento.current = new GameMemento(); GameMemento.current.gameID = gameID; GameMemento.current.hexGridMemento.width = hexGrid.width; GameMemento.current.hexGridMemento.height = hexGrid.height; GameMemento.current.hexGridMemento.size = hexGrid.size; foreach (var item in playerManager.activePlayersName) { GameMemento.current.activePlayersName.Add(item.Key, item.Value); } foreach (var item in playerManager.activePlayersTeam) { GameMemento.current.activePlayersTeam.Add(item.Key, item.Value); } foreach (var item in playerManager.activePlayersFaction) { GameMemento.current.activePlayersFaction.Add(item.Key, item.Value); } foreach (var item in playerManager.activePlayersOrder) { GameMemento.current.activePlayersOrder.Add(item.Key, item.Value); } GameMemento.current.currPlayerOrder = playerManager.currPlayerOrder; GameMemento.current.currPlayer = playerManager.currPlayer; GameMemento.current.aether = currency.aether; GameMemento.current.gold = currency.gold; for (int i = 0; i < hexGrid.cells.Length; i++) { GameMemento.current.hexGridTerrainList.Add(hexGrid.cells[i].terrain); GameMemento.current.hexGridCorpsesList.Add(hexGrid.cells[i].corpses); GameMemento.current.hexGridGroundEffectsList.Add(hexGrid.cells[i].groundEffects); GameMemento.current.hexGridHasVisionList.Add(hexGrid.cells[i].hasVision); GameMemento.current.hexGridFogList.Add(hexGrid.cells[i].fog); if (hexGrid.cells[i].entityObj != null) { EntityMemento entityMemento = new EntityMemento(); SetEntitiesMemento(entityMemento, i); GameMemento.current.entityMementoList.Add(entityMemento); } if (hexGrid.cells[i].buildingObj != null) { BuildingMemento buildingMemento = new BuildingMemento(); SetBuildingsMemento(buildingMemento, i); GameMemento.current.buildingMementoList.Add(buildingMemento); } } }
public override void Restore(EntityMemento memento, LevelEntities entities) { base.Restore(memento, entities); var triggerLinkMemento = (TriggerLinkMemento)memento; LinkedLevel = triggerLinkMemento.LinkedLevel; ForcedLinkColor = triggerLinkMemento.ForcedLinkColor; SpawnPointEntityID = triggerLinkMemento.SpawnPointEntityID; ForceFadeColor = triggerLinkMemento.ForceFadeColor; PlayLinkSound = triggerLinkMemento.PlayLinkSound; entities.Register(this); }
public override void Restore(EntityMemento memento, LevelEntities entities) { base.Restore(memento, entities); var objMemento = (InteractiveObjectSpawnMemento)memento; LBDFile = objMemento.LBDFile; EntityNumber = objMemento.EntityNumber; IdleAnimation = objMemento.IdleAnimation; PlayIdleAnimation = objMemento.PlayIdleAnimation; LuaScript = objMemento.LuaScript; entities.Register(this); if (Application.isPlaying) { spawnObject(); } }
public void SummonEntityMemento(EntityMemento entityMemento) { string playerId = entityMemento.playerID; string entityType = entityMemento.type; int cellIndex = entityMemento.cellIndex; Vector3 summonindex = hexGrid.GetCellPos(cellIndex); summonindex.y = 0.2f; //Instantiate the prefab from the resources folder GameObject entity = (GameObject)Instantiate(Resources.Load(entityType), summonindex, Quaternion.identity); entity.name = entityMemento.uniqueID.ToString(); char playerChar = playerId[0]; entityStorage.PlayerEntityList(playerChar).Add(entity); hexGrid.SetEntityObject(entityMemento.cellIndex, entity); entityStats.SetPlayerID(entity, entityMemento.playerID); entityStats.SetType(entity, entityMemento.type); entityStats.SetUniqueID(entity, entityMemento.uniqueID); entityStats.SetCellIndex(entity, entityMemento.cellIndex); entityStats.SetCurrHealth(entity, entityMemento.currhealth); entityStats.SetMaxHealth(entity, entityMemento.maxhealth); entityStats.SetCurrMana(entity, entityMemento.currmana); entityStats.SetMaxMana(entity, entityMemento.maxmana); entityStats.SetAttackDmg(entity, entityMemento.attackdmg); entityStats.SetCurrAttackPoint(entity, entityMemento.currattackpoint); entityStats.SetMaxAttackPoint(entity, entityMemento.maxattackpoint); entityStats.SetCurrMovementPoint(entity, entityMemento.currmovementpoint); entityStats.SetMaxMovementPoint(entity, entityMemento.maxmovementpoint); entityStats.SetRange(entity, entityMemento.range); entityStats.SetRangedAttackDmg(entity, entityMemento.rangedattackdmg); entityStats.SetArmor(entity, entityMemento.armor); entityStats.SetArmorPiercing(entity, entityMemento.armorpiercing); entityStats.SetRangedArmorPiercing(entity, entityMemento.rangedarmorpiercing); entityStats.SetVision(entity, entityMemento.vision); entityStats.SetPermaEffects(entity, entityMemento.permaEffects); entityStats.SetTempEffects(entity, entityMemento.tempEffects); loadMap.CreateHealthLabel(entityMemento.cellIndex, entityMemento.currhealth, entity.name); }
public EntityMemento ToEntityMemento() { var entityMemento = new EntityMemento { EntityName = this.EntityName, KeyUseGuid = this.KeyProvider == AsKey.UseGuid }; if (this.KeyProvider is KeyProviderByAttributeSet kp) { entityMemento.KeyAttributeNames = kp.AttributeList.ToList(); } if (this.SkipAttributeCriteria is SkipAttributes sa) { entityMemento.AttributesToSkip = sa.AttributesToSkip.ToList(); } entityMemento.OnlyActive = this.OnlyActiveRecords; return(entityMemento); }