public int GetGhostCount(FieldObject o, GhostAttribute gt)
        {
            int count = 0;

            if (o.Equals(FieldObject.P1))
            {
                foreach (Ghost g in gamestate.P1ghostList)
                {
                    if (g.Gt.Equals(gt))
                    {
                        count++;
                    }
                }
            }
            else if (o.Equals(FieldObject.P2))
            {
                foreach (Ghost g in gamestate.P2ghostList)
                {
                    if (g.Gt.Equals(gt))
                    {
                        count++;
                    }
                }
            }

            return(count);
        }
Beispiel #2
0
        /// <summary>
        /// 自身の指定した属性(good もしくは evil)のゴーストのリストを取得する
        /// </summary>
        /// <param name="ghostAttribute">
        /// Type:GhostAttribute good or evil
        /// </param>
        /// <returns>
        /// Type:List<Ghost> ゴーストのリスト
        /// </returns>
        public List <Ghost> GetMyGhostList(GhostAttribute ghostAttribute)
        {
            List <Ghost> glist = new List <Ghost>();

            //getmyghostlistをループ
            foreach (Ghost g in GetMyGhostList())
            {
                if (g.Gt.Equals(ghostAttribute))
                {
                    glist.Add(g);
                }
            }
            return(glist);
        }
Beispiel #3
0
        /// <summary>
        /// 指定したプレイヤーの指定した属性のゴーストの数を取得する
        /// </summary>
        /// <param name="player">
        /// Type:FieldObject P1 or P2
        /// </param>
        /// <param name="ghostAttribute">
        /// Type:GhostAttribute good or evil
        /// </param>
        /// <returns>
        /// ゴーストの数
        /// </returns>
        public int GetGhostNum(FieldObject player, GhostAttribute ghostAttribute)
        {
            int          num   = 0;
            List <Ghost> glist = null;

            //
            if (player.Equals(FieldObject.P1))
            {
                glist = gameState.P1ghostList;
            }
            else if (player.Equals(FieldObject.P2))
            {
                glist = gameState.P2ghostList;
            }

            foreach (Ghost g in glist)
            {
                if (g.Gt.Equals(ghostAttribute))
                {
                    num++;
                }
            }
            return(num);
        }
Beispiel #4
0
        private List <ServableItem> ReflectServableItems()
        {
            // Find all GhostLine API attributes in other assemblies
            Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();

            // check out the assemblies
            foreach (var assembly in assemblies)
            {
                Log("Assembly found: " + assembly.FullName, LogLevel.Verbose);
                if (!assembly.FullName.StartsWith("System.") &&
                    !assembly.FullName.Equals("GhostLineAPI") &&
                    !assembly.FullName.StartsWith("Microsoft"))
                {
                    _monitoredAssemblies.Add(assembly);
                }
            }

            // look for the fields and properties
            foreach (var assembly in _monitoredAssemblies)
            {
                foreach (var typeObj in assembly.GetTypes())
                {
                    PropertyInfo[] props = typeObj.GetProperties();
                    foreach (PropertyInfo prop in props)
                    {
                        object[] attrs = prop.GetCustomAttributes(true);
                        foreach (object attr in attrs)
                        {
                            GhostReadAttribute      gra  = attr as GhostReadAttribute;
                            GhostWriteAttribute     gwa  = attr as GhostWriteAttribute;
                            GhostReadWriteAttribute grwa = attr as GhostReadWriteAttribute;
                            GhostAttribute          ga   = attr as GhostAttribute;
                            if (gra != null || gwa != null || grwa != null)
                            {
                                var servableItem = new ServableItem
                                {
                                    AssemblyFullName = assembly.FullName,
                                    Type             = prop.PropertyType,
                                    PropertyName     = prop.Name
                                };
                                servableItem.GenerateId();


                                var checkItem = _servableItems.FirstOrDefault(si => si.Id == servableItem.Id);

                                if (checkItem != null)
                                {
                                    servableItem = checkItem;
                                }
                                else
                                {
                                    // flesh out the rest
                                    if (_parentObj == null)
                                    {
                                        String message = "Must pass instance object (usually \"this\") when annotating properties due to .NET reflection access restrictions.";
                                        Log(message, LogLevel.Critical);
                                        throw new ArgumentException(message);
                                    }
                                    servableItem.Object       = prop.GetValue(_parentObj);
                                    servableItem.PropertyInfo = prop;
                                }

                                if (gra != null || grwa != null)
                                {
                                    servableItem.CanRead        = true;
                                    servableItem.Version        = ga.Version;
                                    servableItem.OverriddenName = ga.OverrideName;
                                }
                                if (gwa != null || grwa != null)
                                {
                                    servableItem.CanWrite       = true;
                                    servableItem.Version        = ga.Version;
                                    servableItem.OverriddenName = ga.OverrideName;
                                }
                                _servableItems.Add(servableItem);
                            }
                        }
                    }

                    FieldInfo[] fields = typeObj.GetFields();
                    foreach (FieldInfo field in fields)
                    {
                        object[] attrs = field.GetCustomAttributes(true);
                        foreach (object attr in attrs)
                        {
                            GhostReadAttribute      gra  = attr as GhostReadAttribute;
                            GhostWriteAttribute     gwa  = attr as GhostWriteAttribute;
                            GhostReadWriteAttribute grwa = attr as GhostReadWriteAttribute;
                            GhostAttribute          ga   = attr as GhostAttribute;
                            if (gra != null || gwa != null || grwa != null)
                            {
                                var servableItem = new ServableItem
                                {
                                    AssemblyFullName = assembly.FullName,
                                    Type             = field.FieldType,
                                    FieldName        = field.Name,
                                };
                                servableItem.GenerateId();

                                // check to see if this is already a servable item
                                var checkItem = _servableItems.FirstOrDefault(si => si.Id == servableItem.Id);
                                if (checkItem != null)
                                {
                                    servableItem = checkItem;
                                }
                                else
                                {
                                    // flesh out the rest
                                    if (_parentObj == null)
                                    {
                                        String message = "Must pass instance object (usually \"this\") when annotating properties due to .NET reflection access restrictions.";
                                        Log(message, LogLevel.Critical);
                                        throw new ArgumentException(message);
                                    }
                                    servableItem.Object    = field.GetValue(field.Name);
                                    servableItem.FieldInfo = field;
                                }

                                if (gra != null || grwa != null)
                                {
                                    servableItem.CanRead        = true;
                                    servableItem.Version        = ga.Version;
                                    servableItem.OverriddenName = ga.OverrideName;
                                }
                                if (gwa != null || grwa != null)
                                {
                                    servableItem.CanWrite       = true;
                                    servableItem.Version        = ga.Version;
                                    servableItem.OverriddenName = ga.OverrideName;
                                }
                                _servableItems.Add(servableItem);
                            }
                        }
                    }

                    // all properties and fields should now be in _servableItems
                }
            }
            return(_servableItems);
        }
Beispiel #5
0
 /// <summary>
 /// コンストラクタ
 /// </summary>
 /// <param name="gt">
 /// ゴーストの属性
 /// </param>
 /// <param name="initPos">
 /// ゴーストの初期位置
 /// </param>
 public Ghost(GhostAttribute gt, Position initPos)
 {
     Gt      = gt;
     InitPos = initPos;
     P       = initPos;
 }