protected float myRotationSpeed; // The base speed at which this enemy will "turn". //============================================================================= // Default ctor public Enemy() { this.myState = enState.IDLE; this.myType = enType.UNDEF; this.myHealth = 1; this.myDamage = -1; this.myRotationSpeed = 1; }
/// <summary> /// 現在のフレームで、レーダーに表示させたい点を登録する。 /// </summary> /// <param name="type"></param> /// <param name="pos"></param> /// <param name="sizeClass"></param> static public void setLocation(enType type, Vector3 pos, enClass sizeClass) { if (nowIndex >= drawPoints.Length) { return; } drawPoints[nowIndex++] = new DrawPointUnit(type, pos, enClass.normal); }
public void SetValue(Property p) { if (this._type != p.PropType) { Debuger.LogError("类型不同不能设置,属性类型是:{0} 目标类型是:{1}", _type, p.PropType); return; } this._type = p.PropType; this._value = p.Value; }
bool Check(enType t) { if (t == _type || (_type == enType.Int && t == enType.Long) || (_type == enType.Long && t == enType.Int) || (_type == enType.Int && t == enType.Float) ) { return(true); } Debuger.LogError("不能转换。属性类型是:{0} 目标类型是:{1}", _type, t); return(false); }
public override void initInstance(enType type, enColor color, bool isPlayer) { base.initInstance(type, color, true); // The player position is always static, so set it this.transform.position = new Vector3(PersonBrain.minHorPosition, 0.0f, 0.0f); forceStop(); this.gameObject.SetActive(true); this.isRunningAI = true; }
void SetType(enType type) { if (_type == type) { return; } _type = type; if (_type == enType.Bool) { _value = false; } else if (_type == enType.Byte) { _value = (byte)0; } else if (_type == enType.Short) { _value = (short)0; } else if (_type == enType.Int) { _value = (int)0; } else if (_type == enType.Long) { _value = (long)0; } else if (_type == enType.Float) { _value = (float)0; } else if (_type == enType.Double) { _value = (double)0; } else if (_type == enType.String) { _value = ""; } else { Debuger.LogError("未知的类型"); } }
//反序列化 public override void Deserialize(IoBuffer stream) { enType t = (enType)stream.ReadByte(); SetType(t); if (_type == enType.Bool) { _value = stream.ReadBool(); } else if (_type == enType.Byte) { _value = stream.ReadByte(); } else if (_type == enType.Short) { _value = stream.ReadInt16(); } else if (_type == enType.Int) { _value = stream.ReadInt32(); } else if (_type == enType.Long) { _value = stream.ReadInt64(); } else if (_type == enType.Float) { _value = stream.ReadFloat(); } else if (_type == enType.Double) { _value = stream.ReadDouble(); } else if (_type == enType.String) { _value = stream.ReadStr(); } else { Debuger.LogError("未知的类型"); } #if SERIALIZE_DEBUG SerializeUtil.AddLog(this); #endif }
public Property(string value, enType type) { _type = type; switch (_type) { case enType.Int: _value = Convert.ToInt32(value); break; case enType.Long: _value = Convert.ToInt64(value); break; case enType.Float: _value = Convert.ToSingle(value); break; case enType.String: _value = Convert.ToString(value); break; default: { Debuger.LogError("未知的类型"); _value = value as object; }; break; } }
public EN(string enName, List <KeyValuePair <string, string> > enData, TreeNode tn, MasterTypes mType, int mNo, int iNo) { masterType = mType; masterNo = mNo; IEDNo = iNo; SetSupportedAttributes(); //IMP: Call only after master types are set... SetSupportedResponseTypes(); //IMP: Call only after master types are set... SetSupportedDataTypes(); //IMP: Call only after master types are set... //First set the root element value... try { ennType = (enType)Enum.Parse(typeof(enType), enName); } catch (System.ArgumentException) { Utils.WriteLine(VerboseLevel.WARNING, "Enum argument {0} not supported!!!", enName); } //Parse n store values... if (enData != null && enData.Count > 0) { foreach (KeyValuePair <string, string> enkp in enData) { Utils.Write(VerboseLevel.DEBUG, "{0} {1} ", enkp.Key, enkp.Value); try { if (this.GetType().GetProperty(enkp.Key) != null) //Ajay: 10/08/2018 { this.GetType().GetProperty(enkp.Key).SetValue(this, enkp.Value); } } catch (System.NullReferenceException) { Utils.WriteLine(VerboseLevel.WARNING, "Field doesn't exist. XML and class fields mismatch!!! key: {0} value: {1}", enkp.Key, enkp.Value); } } Utils.Write(VerboseLevel.DEBUG, "\n"); } }
//public EN(XmlNode enNode, MasterTypes mType, int mNo, int iNo, bool imported) //{ // masterType = mType; // masterNo = mNo; // IEDNo = iNo; // SetSupportedAttributes();//IMP: Call only after master types are set... // SetSupportedResponseTypes();//IMP: Call only after master types are set... // SetSupportedDataTypes();//IMP: Call only after master types are set... // //Parse n store values... // Utils.WriteLine(VerboseLevel.DEBUG, "enNode name: '{0}'", enNode.Name); // if (enNode.Attributes != null) // { // //First set the root element value... // try // { // ennType = (enType)Enum.Parse(typeof(enType), enNode.Name); // } // catch (System.ArgumentException) // { // Utils.WriteLine(VerboseLevel.WARNING, "Enum argument {0} not supported!!!", enNode.Name); // } // foreach (XmlAttribute item in enNode.Attributes) // { // Utils.Write(VerboseLevel.DEBUG, "{0} {1} ", item.Name, item.Value); // try // { // this.GetType().GetProperty(item.Name).SetValue(this, item.Value); // } catch (System.NullReferenceException) { // Utils.WriteLine(VerboseLevel.WARNING, "Field doesn't exist. XML and class fields mismatch!!! key: {0} value: {1}", item.Name, item.Value); // } // } // Utils.Write(VerboseLevel.DEBUG, "\n"); // } // else if (enNode.NodeType == XmlNodeType.Comment) // { // isNodeComment = true; // comment = enNode.Value; // } // if (imported)//Generate a new unique id... // { // this.ENNo = (Globals.ENNo + 1).ToString(); // if (masterType == MasterTypes.IEC103) // { // //Commented as asked by Amol, 29/12/2k16: this.Index = (Globals.ENIndex + 1).ToString(); // } // else if (masterType == MasterTypes.ADR) // { // //Commented as asked by Amol, 29/12/2k16: this.Index = (Globals.ENIndex + 1).ToString(); // } // else if (masterType == MasterTypes.MODBUS) // { // //Commented as asked by Amol, 29/12/2k16: this.Index = (Globals.ENIndex + 1).ToString(); // } // else if (masterType == MasterTypes.IEC101) // { // //Commented as asked by Amol, 29/12/2k16: this.Index = (Globals.ENIndex + 1).ToString(); // } // } //} public EN(XmlNode enNode, MasterTypes mType, int mNo, int iNo, bool imported) { masterType = mType; masterNo = mNo; IEDNo = iNo; SetSupportedAttributes(); //IMP: Call only after master types are set... SetSupportedResponseTypes(); //IMP: Call only after master types are set... SetSupportedDataTypes(); //IMP: Call only after master types are set... //Parse n store values... Utils.WriteLine(VerboseLevel.DEBUG, "enNode name: '{0}'", enNode.Name); if (enNode.Attributes != null) { //First set the root element value... try { ennType = (enType)Enum.Parse(typeof(enType), enNode.Name); } catch (System.ArgumentException) { Utils.WriteLine(VerboseLevel.WARNING, "Enum argument {0} not supported!!!", enNode.Name); } if (masterType == MasterTypes.ADR || masterType == MasterTypes.IEC101 || masterType == MasterTypes.IEC103 || masterType == MasterTypes.MODBUS || masterType == MasterTypes.Virtual) { foreach (XmlAttribute item in enNode.Attributes) { Utils.Write(VerboseLevel.DEBUG, "{0} {1} ", item.Name, item.Value); try { if (this.GetType().GetProperty(item.Name) != null) //Ajay: 10/08/2018 { this.GetType().GetProperty(item.Name).SetValue(this, item.Value); } } catch (System.NullReferenceException) { Utils.WriteLine(VerboseLevel.WARNING, "Field doesn't exist. XML and class fields mismatch!!! key: {0} value: {1}", item.Name, item.Value); } } } //Namrata: 17/7/2017 // If master Type is IEC61850Client if (masterType == MasterTypes.IEC61850Client) { if (enNode.Name == "EN") { foreach (XmlAttribute xmlattribute in enNode.Attributes) { try { if (xmlattribute.Name == "ResponseType") { Iec61850ResponseType = enNode.Attributes[1].Value; } else if (xmlattribute.Name == "Index") { Iec61850Index = enNode.Attributes[2].Value; } else if (xmlattribute.Name == "FC") { fc = enNode.Attributes[3].Value; } else { if (this.GetType().GetProperty(xmlattribute.Name) != null) //Ajay: 10/08/2018 { this.GetType().GetProperty(xmlattribute.Name).SetValue(this, xmlattribute.Value); } } } catch (System.NullReferenceException) { Utils.WriteLine(VerboseLevel.WARNING, "DI: Field doesn't exist. XML and class fields mismatch!!! key: {0} value: {1}", xmlattribute.Name, xmlattribute.Value); } } } } Utils.Write(VerboseLevel.DEBUG, "\n"); } else if (enNode.NodeType == XmlNodeType.Comment) { isNodeComment = true; comment = enNode.Value; } if (imported)//Generate a new unique id... { this.ENNo = (Globals.ENNo + 1).ToString(); if (masterType == MasterTypes.IEC103) { //Commented as asked by Amol, 29/12/2k16: this.Index = (Globals.ENIndex + 1).ToString(); } else if (masterType == MasterTypes.ADR) { //Commented as asked by Amol, 29/12/2k16: this.Index = (Globals.ENIndex + 1).ToString(); } else if (masterType == MasterTypes.MODBUS) { //Commented as asked by Amol, 29/12/2k16: this.Index = (Globals.ENIndex + 1).ToString(); } else if (masterType == MasterTypes.IEC101) { //Commented as asked by Amol, 29/12/2k16: this.Index = (Globals.ENIndex + 1).ToString(); } } }
public Property(string s) { _type = enType.String; _value = s; }
public Property(long l) { _type = enType.Long; _value = l; }
public Property(int i) { _type = enType.Int; _value = i; }
public Property(enType t) { _type = t; }
public Property(Property p) { this._type = p.PropType; this._value = p.Value; }
public Property(float f) { _type = enType.Float; _value = f; }
public DrawPointUnit(enType t, Vector3 p, enClass c) { type = t; position = p; sizeClass = c; }
/** * Initialize a interactive instance * * @param type The type of the person * @param color The color of the person */ public virtual void initInstance(enType type, enColor color, bool isPlayer = false) { Color32 c32; // Set the instance's properties this.type = type; this.color = color; // Make sure this person can be bribed/influenced this.state = enState.free; this.isWhite = false; this.dir = enDir.none; // Always start on idle forceAIState(enAIState.idle); this.sprBody = null; this.fixLayer = this.GetComponentInChildren<FixLayer>(); if (this.fixLayer != null) { this.fixLayer.fixLayer(this, isPlayer); this.sprBody = this.fixLayer.getBody(); } switch(type) { case enType.level_0: this.fixLayer.setType(0); break; case enType.level_1: this.fixLayer.setType(1); break; case enType.level_2: this.fixLayer.setType(2); break; } switch (this.color) { case enColor.red: c32 = new Color32(0xed, 0x6a, 0x6a, 0xff); break; case enColor.green: c32 = new Color32(0x3e, 0xb7, 0x79, 0xff); break; case enColor.blue: c32 = new Color32(0x54, 0x57, 0x9e, 0xff); break; case enColor.magenta: c32 = new Color32(0xda, 0x71, 0xb0, 0xff); break; case enColor.cyan: c32 = new Color32(0x69, 0xb6, 0xd3, 0xff); break; case enColor.yellow: c32 = new Color32(0xe1, 0xda, 0x4f, 0xff); break; case enColor.black: c32 = new Color32(0xff, 0xff, 0xff, 0xff); break; case enColor.white: c32 = new Color32(0xff, 0xff, 0xff, 0xff); break; default: c32 = new Color32(0xff, 0xff, 0xff, 0xff); break; } if (this.sprBody) { this.sprBody.color = new Color((float)c32.r / 255.0f, (float)c32.g / 255.0f, (float)c32.b / 255.0f); } // Randomize the position this.transform.position = new Vector3(Random.Range( PersonBrain.minHorPosition + 0.5f, PersonBrain.maxHorPosition - 0.5f), 0, 0); // Activate the object's physics/behavious/etc this.gameObject.SetActive(true); }