Beispiel #1
0
    public void _Execute(MinEventParams _params)
    {
        bool netSync  = !_params.Self.isEntityRemote | _params.IsLocal;
        int  entityId = _params.Self.entityId;

        for (int j = 0; j < this.targets.Count; j++)
        {
            string buff = "";
            if (this.targets[j] is EntityPlayer)
            {
                buff = this.buffNames[0];
            }
            else if (this.targets[j] is EntityZombie)
            {
                buff = this.buffNames[1];
            }
            else if (this.targets[j] is EntityAnimal)
            {
                buff = this.buffNames[2];
            }
            else
            {
                buff = this.buffNames[3];
            }
            if (BuffManager.GetBuff(buff) == null)
            {
                continue;
            }
            this.targets[j].Buffs.AddBuff(buff, entityId, netSync, false);
        }
    }
Beispiel #2
0
    public override void Execute(MinEventParams _params)
    {
        for (int i = 0; i < this.buffNames.Length; i++)
        {
            if (BuffManager.GetBuff(this.buffNames[i]) != null)
            {
                for (int j = 0; j < this.targets.Count; j++)
                {
                    Debug.Log(" Target: " + targets[j].EntityName + " Faction: " + targets[j].factionId);
                    Debug.Log(" Self: " + _params.Self.EntityName + " Faction: " + _params.Self.factionId);

                    // Check to make sure that the faction is the same
                    if (MustMatch)
                    {
                        if (this.targets[j].factionId == _params.Self.factionId)
                        {
                            this.targets[j].Buffs.AddBuff(this.buffNames[i], _params.Self.entityId, !_params.Self.isEntityRemote);
                        }
                    }
                    else
                    {
                        if (this.targets[j].factionId != _params.Self.factionId)
                        {
                            this.targets[j].Buffs.AddBuff(this.buffNames[i], _params.Self.entityId, !_params.Self.isEntityRemote);
                        }
                    }
                }
            }
        }
    }
    public void OnCollisionEnter2D(Collision2D other)
    {
        if (other.gameObject.tag == "Block")
        {
            _buffManager.GetBuff(other.transform.position);
            other.gameObject.GetComponent <Block>().DoDamage();
        }
        else if (other.gameObject.tag == "Racket")
        {
            float factor = HitFactor(transform.position,
                                     other.transform.position,
                                     other.collider.bounds.size.x);

            Vector2 dir = new Vector2(factor, 1).normalized;
            GetComponent <Rigidbody2D>().velocity = dir * _ballSpeed;
        }
        else if (other.gameObject.name == "Bottom Border")
        {
            HitBottomBorder();
        }
    }
Beispiel #4
0
    public void AddBuff(int buffID, Entity caster = null)
    {
        BuffBase buff = BuffManager.GetBuff(buffID, m_entity, caster);

        if (buff == null)
        {
            Log.Error("找不到buffID = " + buffID);
            return;
        }

        if (m_dicBuff.ContainsKey(buffID))
        {
            m_dicBuff[buffID].leftTime = buff.buffInfo.KeepTime;
        }
        else
        {
            buff.leftTime = buff.buffInfo.KeepTime;
            buff.BuffStart();
            m_dicBuff.Add(buffID, buff);
        }
    }
    public override void PerformAction()
    {
        EntityAlive myEntity = null;

        if (OwnerQuest.OwnerJournal.OwnerPlayer != null)
        {
            myEntity = OwnerQuest.OwnerJournal.OwnerPlayer as EntityAlive;
        }

        if (myEntity != null)
        {
            myEntity.PlayOneShot(base.ID, true);
            BuffClass buff = BuffManager.GetBuff(base.Value);
            if (buff != null)
            {
                if (!myEntity.Buffs.HasBuff(base.Value))
                {
                    myEntity.Buffs.AddBuff(base.Value);
                }
            }
        }
    }
Beispiel #6
0
        public static void LoadXml()
        {
            if (!Utils.FileExists(filePath))
            {
                UpdateXml();
            }
            XmlDocument xmlDoc = new XmlDocument();

            try
            {
                xmlDoc.Load(filePath);
            }
            catch (XmlException e)
            {
                Log.Error(string.Format("[SERVERTOOLS] Failed loading {0}: {1}", file, e.Message));
                return;
            }
            XmlNode _XmlNode = xmlDoc.DocumentElement;

            foreach (XmlNode childNode in _XmlNode.ChildNodes)
            {
                if (childNode.Name == "Prayers")
                {
                    Dict.Clear();
                    foreach (XmlNode subChild in childNode.ChildNodes)
                    {
                        if (subChild.NodeType == XmlNodeType.Comment)
                        {
                            continue;
                        }
                        if (subChild.NodeType != XmlNodeType.Element)
                        {
                            Log.Warning(string.Format("[SERVERTOOLS] Unexpected XML node found in 'Prayers' section: {0}", subChild.OuterXml));
                            continue;
                        }
                        XmlElement _line = (XmlElement)subChild;
                        if (!_line.HasAttribute("Name"))
                        {
                            Log.Warning(string.Format("[SERVERTOOLS] Ignoring Prayer entry because of missing Name attribute: {0}", subChild.OuterXml));
                            continue;
                        }
                        if (!_line.HasAttribute("Message"))
                        {
                            Log.Warning(string.Format("[SERVERTOOLS] Ignoring Prayer entry because of missing Message attribute: {0}", subChild.OuterXml));
                            continue;
                        }
                        string    _buff    = _line.GetAttribute("Name");
                        string    _message = _line.GetAttribute("Message");
                        BuffClass _class   = BuffManager.GetBuff(_buff);
                        if (_class == null)
                        {
                            Log.Warning(string.Format("[SERVERTOOLS] Ignoring Prayer entry because buff was not valid: {0}", subChild.OuterXml));
                            continue;
                        }
                        if (!Dict.ContainsKey(_buff))
                        {
                            Dict.Add(_buff, _message);
                        }
                    }
                }
            }
        }
Beispiel #7
0
 public static void LoadXml()
 {
     try
     {
         if (!File.Exists(FilePath))
         {
             UpdateXml();
         }
         XmlDocument xmlDoc = new XmlDocument();
         try
         {
             xmlDoc.Load(FilePath);
         }
         catch (XmlException e)
         {
             Log.Error(string.Format("[SERVERTOOLS] Failed loading {0}: {1}", file, e.Message));
             return;
         }
         bool        upgrade    = true;
         XmlNodeList childNodes = xmlDoc.DocumentElement.ChildNodes;
         if (childNodes != null)
         {
             Dict.Clear();
             for (int i = 0; i < childNodes.Count; i++)
             {
                 if (childNodes[i].NodeType != XmlNodeType.Comment)
                 {
                     XmlElement line = (XmlElement)childNodes[i];
                     if (line.HasAttributes)
                     {
                         if (line.HasAttribute("Version") && line.GetAttribute("Version") == Config.Version)
                         {
                             upgrade = false;
                             continue;
                         }
                         else if (line.HasAttribute("Name") && line.HasAttribute("Message"))
                         {
                             string    buff    = line.GetAttribute("Name");
                             string    message = line.GetAttribute("Message");
                             BuffClass _class  = BuffManager.GetBuff(buff);
                             if (_class == null)
                             {
                                 Log.Warning(string.Format("[SERVERTOOLS] Ignoring Prayer.xml entry. Buff is not valid: {0}", line.OuterXml));
                                 continue;
                             }
                             if (!Dict.ContainsKey(buff))
                             {
                                 Dict.Add(buff, message);
                             }
                         }
                     }
                 }
             }
         }
         if (upgrade)
         {
             XmlNodeList nodeList = xmlDoc.DocumentElement.ChildNodes;
             XmlNode     node     = nodeList[0];
             XmlElement  line     = (XmlElement)nodeList[0];
             if (line != null)
             {
                 if (line.HasAttributes)
                 {
                     OldNodeList = nodeList;
                     File.Delete(FilePath);
                     UpgradeXml();
                     return;
                 }
                 else
                 {
                     nodeList = node.ChildNodes;
                     line     = (XmlElement)nodeList[0];
                     if (line != null)
                     {
                         if (line.HasAttributes)
                         {
                             OldNodeList = nodeList;
                             File.Delete(FilePath);
                             UpgradeXml();
                             return;
                         }
                     }
                     File.Delete(FilePath);
                     UpdateXml();
                     Log.Out(string.Format("[SERVERTOOLS] The existing Prayer.xml was too old or misconfigured. File deleted and rebuilt for version {0}", Config.Version));
                 }
             }
         }
     }
     catch (Exception e)
     {
         if (e.Message == "Specified cast is not valid.")
         {
             File.Delete(FilePath);
             UpdateXml();
         }
         else
         {
             Log.Out(string.Format("[SERVERTOOLS] Error in Prayer.LoadXml: {0}", e.Message));
         }
     }
 }