public GameAttributeInstance AddAttribute(GameAttribute attribute) { GameAttributeInstance attr = new GameAttributeInstance(this.m_Owner, attribute); AddAttribute(attr); return(attr); }
private static RegistryKey getKeyForGame(Game game, bool create) { RegistryKey currentuser = Registry.CurrentUser; RegistryKey software = currentuser.OpenSubKey("Software", true); if (software == null) { software = currentuser.CreateSubKey("Software"); } RegistryKey chessv = software.OpenSubKey("ChessV", true); if (chessv == null) { chessv = software.CreateSubKey("ChessV"); } RegistryKey games = chessv.OpenSubKey("Games", true); if (games == null) { games = chessv.CreateSubKey("Games"); } GameAttribute attr = game.GameAttribute; string baseGameName = attr.GameName; RegistryKey key = games.OpenSubKey(attr.GameName, true); if (key != null || !create) { return(key); } return(games.CreateSubKey(attr.GameName)); }
// Use this for initialization void Start() { instance = this; moveDirection = Vector3.right; gameAttribute = GameAttribute.instance; InitialSpeed = GameData.getPlayerInitialSpeed(); if (GameData.getCurrentWeaponIndex() > 0) { isPlayerHasWeapon = true; } else { isPlayerHasWeapon = false; } if (GameData.getCurrentWeaponAmmoLeft() > 0 || GameData.getCurrentWeaponAmmoUsing() > 0) { isWeaponHasAmmo = true; } else { isWeaponHasAmmo = false; } if (GameMaster.isGodMode == true) { InitialSpeed = 20; } Invoke("WaitStart", 0.2f); }
protected override void RegistAttribute() { base.RegistAttribute(); _cfg = BossConfig.GetData(Id); gameObject.name = _cfg.Name; var _hp = new GameRangeAttribute(E_Attribute.Hp.ToString(), 0, _cfg.Hp); m_Hp = AddRangeAttribute(_hp); var _mp = new GameRangeAttribute(E_Attribute.Mp.ToString(), 0, _cfg.Mp, 0.1f); m_Mp = AddRangeAttribute(_mp); var _attack = new GameAttribute(E_Attribute.Atk.ToString(), _cfg.Attack); m_Attack = AddAttribute(_attack); var _moveSpeed = new GameAttribute(E_Attribute.MoveSpeed.ToString(), _cfg.MoveSpeed); m_MoveSpeed = AddAttribute(_moveSpeed); m_CaculateDelta = TimerManager.Instance.AddListener(0, 0.02f, m_MonoAttribute.CaculateRangeDelta, null, true); _shield = new GameRangeAttribute(E_Attribute.Shield.ToString(), 0, _cfg.Shield, 0.02f); m_Shield = AddRangeAttribute(_shield); UIBattleWindow.ShowBossUI(); UIBattleWindow.OnBossHpChange(m_Hp.Current, m_Hp.GetMinTotalValue(), m_Hp.GetMaxTotalValue()); UIBattleWindow.OnBossShieldChange(m_Shield.Current, m_Shield.GetMinTotalValue(), m_Shield.GetMaxTotalValue()); GetRangeAttribute(E_Attribute.Hp.ToString()).OnValueChanged += (delta) => { UIBattleWindow.OnBossHpChange(m_Hp.Current, m_Hp.GetMinTotalValue(), m_Hp.GetMaxTotalValue()); }; GetRangeAttribute(E_Attribute.Shield.ToString()).OnValueChanged += (delta) => { UIBattleWindow.OnBossShieldChange(m_Shield.Current, m_Shield.GetMinTotalValue(), m_Shield.GetMaxTotalValue()); }; AudioManager.Instance.PlayBGM(_cfg.FightBGM); }
public void gameApmTest(Text text) { gameApmTest_count++; text.text = "gameApmTest start, count: " + gameApmTest_count + "\n"; GameAttribute attribute = new GameAttribute("new scene", GameAttribute.LoadingState.NOT_LOADING); text.text += "create new attribute success\n"; APMS.getInstance().startGamePlugin(); text.text += "GameAPM start\n"; APMS.getInstance().enableGamePlugin(true); text.text += "enableGamePlugin: true\n"; sceneHandler = APMS.getInstance().startLoadingScene(attribute); text.text += "startLoadingScene, sceneHandler= " + sceneHandler + "\n"; APMS.getInstance().setCurrentGameAttribute(attribute); text.text += "setCurrentGameAttribute\n"; APMS.getInstance().setReportRate(1); text.text += "setReportRate\n"; text.text += "gameApmTest success\n\n"; }
void SetAttributeValue(GameAttribute attribute, int?key, GameAttributeValue value) { KeyId keyid; keyid.Id = attribute.Id; keyid.Key = key; if (!_changedAttributes.Contains(keyid)) { _changedAttributes.Add(keyid); } if (attribute.EncodingType == GameAttributeEncoding.IntMinMax) { if (value.Value < attribute.Min.Value || value.Value > attribute.Max.Value) { throw new ArgumentOutOfRangeException("GameAttribute." + attribute.Name.Replace(' ', '_'), "Min: " + attribute.Min.Value + " Max: " + attribute.Max.Value + " Tried to set: " + value.Value); } } else if (attribute.EncodingType == GameAttributeEncoding.Float16) { if (value.ValueF < GameAttribute.Float16Min || value.ValueF > GameAttribute.Float16Max) { throw new ArgumentOutOfRangeException("GameAttribute." + attribute.Name.Replace(' ', '_'), "Min: " + GameAttribute.Float16Min + " Max " + GameAttribute.Float16Max + " Tried to set: " + value.ValueF); } } _attributeValues[keyid] = value; }
private void SetAttributeValue(GameAttribute attribute, int?key, GameAttributeValue value) { // error if scripted attribute and is not settable if (attribute.ScriptFunc != null && !attribute.ScriptedAndSettable) { var frame = new System.Diagnostics.StackFrame(2, true); Logger.Error("illegal value assignment for GameAttribute.{0} attempted at {1}:{2}", attribute.Name, frame.GetFileName(), frame.GetFileLineNumber()); } if (attribute.EncodingType == GameAttributeEncoding.IntMinMax) { if (value.Value < attribute.Min.Value || value.Value > attribute.Max.Value) { throw new ArgumentOutOfRangeException("GameAttribute." + attribute.Name.Replace(' ', '_'), "Min: " + attribute.Min.Value + " Max: " + attribute.Max.Value + " Tried to set: " + value.Value); } } else if (attribute.EncodingType == GameAttributeEncoding.Float16) { if (value.ValueF < GameAttribute.Float16Min || value.ValueF > GameAttribute.Float16Max) { throw new ArgumentOutOfRangeException("GameAttribute." + attribute.Name.Replace(' ', '_'), "Min: " + GameAttribute.Float16Min + " Max " + GameAttribute.Float16Max + " Tried to set: " + value.ValueF); } } RawSetAttributeValue(attribute, key, value); }
// Use this for initialization void Start() { instance = this; coin = 0; life = 1; multiply = 1; }
private void ResolveAttribute(GameAttribute attribute, string identifier = "") { identifier = identifier == "" ? ATTRIBUTE_IDENTIFIER + attribute.Abbreviation.ToLower() : identifier; int index; //$this.name if ((index = resolvedText.IndexOf(identifier)) != -1) { int end = resolvedText.IndexOf(' ', index); int start = resolvedText.IndexOf('.', index, end) + 1; end -= start; string propName = "current"; string replace = identifier; if (start != 0) { propName = resolvedText.Substring(start, end); replace = identifier + "." + propName; } object value = attribute.GetType().GetProperty(propName[0].ToString().ToUpper() + propName.Substring(1)).GetValue(attribute); resolvedText = resolvedText.Replace(replace, value.ToString()); } }
// Use this for initialization void Start() { gameAttribute = this; // 加载新场景时不销毁 DontDestroyOnLoad(this); StartCoroutine(initAttribute()); }
public Projectile(int minDmg, int maxDmg, bool left, int width, int height) { Damage = new GameAttribute(minDmg, maxDmg); Left = left; Width = width; Height = height; }
public GameInitializationException (GameAttribute gameAttribute, string message, Exception innerException = null) : base(message, innerException) { GameAttribute = gameAttribute; }
public GameRangeAttribute(string name, float minValue, float maxValue, float delta = 0, string description = "") { this.Name = name; this.Description = description; this.Min = new GameAttribute("Min_" + name, minValue); this.Max = new GameAttribute("Max_" + name, maxValue); this.Delta = new GameAttribute("Delta_" + name, delta); }
// Use this for initialization void Start() { //金币重置 coin = 0; //设置全局实例 instance = this; }
// Use this for initialization void Start() { initialTime = Time.time; initialTimeNum = MoveTime; controller = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController>(); direction = controller.direction; gameAttribute = GameAttribute.instance; }
private void btnCalculate_Click(object sender, EventArgs e) { int nFiles = Convert.ToInt32(txtNumberOfFiles.Text); int nRanks = Convert.ToInt32(txtNumberOfRanks.Text); GameAttribute attr = new GameAttribute("", typeof(Geometry.Rectangular), nFiles, nRanks); Games.Abstract.UndefinedGame.PieceTypeList = new List <PieceType>(); types = new List <PieceType>(); addPieceType(typeof(Queen), "Q"); addPieceType(typeof(Rook), "R"); addPieceType(typeof(Bishop), "B"); addPieceType(typeof(Knight), "N"); addPieceType(typeof(Amazon), "QN"); addPieceType(typeof(Chancellor), "RN"); addPieceType(typeof(Archbishop), "BN"); addPieceType(typeof(Nightrider), "NN"); addPieceType(typeof(Unicorn), "BNN"); addPieceType(typeof(Champion), "WDA"); addPieceType(typeof(Wizard), "FC"); addPieceType(typeof(Lion), "HFD"); addPieceType(typeof(WarElephant), "FAD"); addPieceType(typeof(Phoenix), "WA"); addPieceType(typeof(Cleric), "BD"); addPieceType(typeof(ShortRook), "R4"); addPieceType(typeof(Bowman), "WD"); addPieceType(typeof(NarrowKnight), "fbNF"); addPieceType(typeof(ChargingRook), "frlRbK"); addPieceType(typeof(ChargingKnight), "fhNrlbK"); addPieceType(typeof(Colonel), "fhNfrlRbK"); ChessV.Games.Abstract.UndefinedGame game = new Games.Abstract.UndefinedGame(2, nFiles, nRanks); game.Initialize(new GameAttribute("", typeof(Geometry.Rectangular), nFiles, nRanks), null, null); StringBuilder str = new StringBuilder(); foreach (PieceType type in types) { type.CalculateMobilityStatistics(game, (double)1.0 - ((double)densities[0] / 100.0)); str.Append(type.InternalName); str.Append('\t'); str.Append(type.Notation); str.Append('\t'); str.Append(type.AverageDirectionsAttacked.ToString("F2")); str.Append('\t'); str.Append(type.AverageSafeChecks.ToString("F2")); str.Append('\t'); str.Append(type.AverageMobility.ToString("F2")); for (int x = 1; x < densities.Length; x++) { type.CalculateMobilityStatistics(game, (double)1.0 - ((double)densities[x] / 100.0)); str.Append('\t'); str.Append(type.AverageMobility.ToString("F2")); } str.Append('\n'); } Clipboard.SetText(str.ToString()); }
public AttributeText(GameAttribute linkedAttribute) { LinkedAttribute = linkedAttribute; DependantAttributes = new List <GameAttribute>(); RoundDecimals = DEFAULT_ROUND_DECIMALS; OpeningExpressionDelimiter = DEFAULT_OPENING_EXPRESSION_DELIMITER; ClosingExpressionDelimiter = DEFAULT_CLOSING_EXPRESSION_DELIMITER; }
// Use this for initialization void Start() { initialTime = Time.time; sayTime = Time.time; instance = this; moveDirection = Vector3.right; gameAttribute = GameAttribute.instance; InitialSpeed = 5; Invoke("WaitStart", 0.2f); }
public void Parse(GameBitBuffer buffer) { if (buffer.ReadBool()) { Field0 = buffer.ReadInt(20); } int index = buffer.ReadInt(10) & 0xFFF; Attribute = GameAttribute.Attributes[index]; }
public MainWindow() { InitializeComponent(); //Console.WriteLine(234.567.ToString("0.", CultureInfo.InvariantCulture)); /*GameAttribute a = new GameAttribute(); * a.Current = 4.255467346436367; * a.Max = 100.0; * a.Min = 0.0; * a.FormatString = "$cur% / $max%"; * a.Abbreviation = "STR"; * * AttributeDescriptor text = new AttributeDescriptor(a); * text.SimpleText = "increase life by {$this.current * 5}"; * Console.WriteLine(text.GetResolvedText()); * * * Console.WriteLine(a.Text);*/ /*DataFile file = new DataFile(); * file.bytes = System.IO.File.ReadAllBytes("pc_arch_yakuza_mansion.bin").ToList(); * file.WriteToFile(new System.IO.FileInfo("test.txt"));*/ Debug.DebugMessagesEnabled = true; GameAttribute str = new GameAttribute("Strength"); str.Abbreviation = "STR"; str.Min = 0; str.Max = 100; str.Set(500); // trigger str.Set(10); str.Decrease(30); // trigger Console.WriteLine(str.Current); str.Increase(200); // trigger str.Decrease(85); Console.WriteLine(str.Current); DerivedGameAttribute crit = new DerivedGameAttribute("Critical"); crit.DependantAttributes.Add(str); crit.Max = 100; crit.Min = 0; crit.ValueExpression.SimpleText = "$str * 3.552"; crit.FormatString = "$cur.1% / $max%"; Console.WriteLine(crit.DefaultText); Resource hp = new Resource("Health Points"); hp.Abbreviation = "HP"; hp.Max = 200; hp.Set(87); hp.FormatString = "$cur / $max || $per.1%"; Console.WriteLine(hp.DefaultText); }
private GameAttributeValue GetAttributeValue(GameAttribute attribute, int?key) { if (attribute.ScriptFunc != null) { return(attribute.ScriptFunc(this, key)); } else { return(RawGetAttributeValue(attribute, key)); } }
private void Shot() { //initEffect (GunEffect); if (isPlayerHasWeapon) { if (isWeaponHasAmmo) { initPrefab(BulletPrefab, new Vector3(0, -0.05f, 0)); GameAttribute.clipUpdate(); getAuidoByWeaponIndex(GameData.getCurrentWeaponIndex()); } } }
private static bool LoadAttribute(int powerSNO, GameAttributeMap attributes, int attributeId, out float result) { GameAttribute attr = GameAttribute.Attributes[attributeId]; bool needs_key = _powerKeyedAttributes.Contains(attributeId); if (attr is GameAttributeF) { if (needs_key) { result = attributes[(GameAttributeF)attr, powerSNO]; } else { result = attributes[(GameAttributeF)attr]; } return(true); } else if (attr is GameAttributeI) { if (needs_key) { result = (float)attributes[(GameAttributeI)attr, powerSNO]; } else { result = (float)attributes[(GameAttributeI)attr]; } return(true); } else if (attr is GameAttributeB) { if (needs_key) { result = attributes[(GameAttributeB)attr, powerSNO] ? 1 : 0; } else { result = attributes[(GameAttributeB)attr] ? 1 : 0; } return(true); } else { Logger.Error("invalid attribute {0}", attributeId); result = 0; return(false); } }
// Use this for initialization void Start() { instance = this; Score = long.Parse(GameData.getScore()); Gold = GameData.getGold(); initialClip = GameData.getCurrentWeaponAmmoInitial(); Clip = GameData.getCurrentWeaponAmmoUsing(); LeftClip = GameData.getCurrentWeaponAmmoLeft(); playerMaxHealth = GameData.getMaxHealth(); playerCurrentHealth = GameData.getCurrentHealth(); initialByLevel(); initialTime = Time.time; currentWeaponIndex = GameData.getCurrentWeaponIndex(); }
void Start(){ //Setup all attribute gameAttribute = this; DontDestroyOnLoad(this); speed = starterSpeed; distance = 0; coin = 0; life = starterLife; level = 0; pause = false; deleyDetect = false; ageless = false; isPlaying = true; }
// *** OPERATIONS *** // #region CreateGame public Game CreateGame (string name, // name of game to create Dictionary <string, string> definitions = null, // optional dict of defined Game Variables InitializationHelper initHelper = null) // optional init helper (null if non-interactive) { // look up the Type of the requested Game class Type gameClass = GameClasses[name]; // look up the GameAttribute of the requested game GameAttribute gameAttribute = GameAttributes[name]; // use reflection to find the default constructor ConstructorInfo ci = gameClass.GetConstructor(new Type[] { }); if (ci == null) { // No appropriate constructor found. // This is probably a template (abstract) Game return(null); } // invoke the constructor to create the game object Game newgame; try { newgame = (Game)ci.Invoke(null); } catch (Exception ex) { throw new Exceptions.GameInitializationException(gameAttribute, "Exception in Manager.CreateGame: failed to create game", ex); } // find the Game's Environment field and set it to a newly // constructed interpreter/compiler Environment with this Manager's // global Environment as the parent Environment. FieldInfo environmentField = newgame.GetType().GetField("Environment"); if (environmentField != null) { environmentField.SetValue(newgame, new Compiler.Environment(Environment)); } // initialize the Game with the Initialize method - this is essential newgame.Initialize(gameAttribute, definitions, initHelper); // return newly constructed Game object return(newgame); }
void Start() { //Setup all attribute gameAttribute = this; DontDestroyOnLoad(this); speed = starterSpeed; distance = 0; coin = 0; life = starterLife; level = 0; pause = false; deleyDetect = false; ageless = false; isPlaying = true; }
// Update is called once per frame void Update() { if (gameAttribute == null) { gameAttribute = GameAttribute.instance; } if (GameMaster.instance.isGameOver != true) { ScoreText.text = gameAttribute.Score.ToString(); setTimeText(); GoldText.text = gameAttribute.Gold.ToString(); setWeapon(); setCurrentHPText(); } }
GameAttributeValue GetAttributeValue(GameAttribute attribute, int?key) { KeyId keyid; keyid.Id = attribute.Id; keyid.Key = key; GameAttributeValue gaValue; if (_attributeValues.TryGetValue(keyid, out gaValue)) { return(gaValue); } return(attribute._DefaultValue); }
public override void ImproveAbility <T>() { GameAttribute atrib = GetAttribute <T>(); int val = (int)atrib.Amount; int cost = (val - 12) / 2; cost = (cost <= 0) ? 1 : cost; if (AttributePoints >= cost) { AttributePoints -= cost; atrib.Amount++; } }
void Start() { //Setup all attribute Instance = this; //DontDestroyOnLoad(this); speed = starterSpeed; //time = 120.0f; rtime = time; //Distance = 0; remainDistance = FinalDistance - Distance; fish = 0; life = starterLife; //level = 1; pause = false; deleyDetect = false; ageless = false; isPlaying = true; clock = Timekeeper.instance.Clock("enemies"); }
public Entity(int maxHealth) { airTime = new ATimer(); airTime.Interval = 100f; airTime.TimerType = ATimerType.MilliSeconds; airTime.Stop(); Owner = ProjectileOwner.None; pos = Vector2.Zero; startPosition = Vector2.Zero; DrawColor = Color.White; CollisionRectangle = new Rectangle(0, 0, WIDTH, HEIGHT); Health = new GameAttribute(0, maxHealth); Position = Vector2.Zero; Friction = 0.2f; HasGravity = true; HasWorldCollision = true; }
// *** HELPER FUNCTIONS *** // #region loadGamesFromModule protected void loadGamesFromModule(Module module) { Type[] types = module.GetTypes(); foreach (Type type in types) { object[] customAttrs = type.GetCustomAttributes(typeof(GameAttribute), false); if (customAttrs != null && customAttrs.Length >= 1) { foreach (object attr in customAttrs) { GameAttribute gameAttribute = (GameAttribute)attr; GameClasses.Add(gameAttribute.GameName, type); GameAttributes.Add(gameAttribute.GameName, gameAttribute); Environment.AddSymbol(gameAttribute.GameName, type); object[] appearanceAttrs = type.GetCustomAttributes(typeof(AppearanceAttribute), false); if (appearanceAttrs != null && customAttrs.Length >= 1) { foreach (object attr2 in appearanceAttrs) { AppearanceAttribute appearance = (AppearanceAttribute)attr2; if (appearance.Game != null) { if (AppearanceAttributes.ContainsKey(appearance.Game)) { AppearanceAttributes[appearance.Game] = appearance; } else { AppearanceAttributes.Add(appearance.Game, appearance); } } else { AppearanceAttributes.Add(gameAttribute.GameName, appearance); } } } } } } }
public void Parse(GameBitBuffer buffer) { if(buffer.ReadBool()) Field0 = buffer.ReadInt(20); Field1 = GameAttribute.Attributes[buffer.ReadInt(10)]; }
public static Game CreateGame(Type type, GameAttribute attr) { return (Game) Activator.CreateInstance(type, attr.Id, CreateGameSettings(type)); }