Esempio n. 1
0
    public static object ReadComponent(GameObject gameObject, string entire_name, string st, Type gOType, object obj, ReadSimpleProperty ReadSimpleProperty)
    {
        ////Debug.unityLogger.logEnabled = false;
        string parentName = st.Substring(0, st.IndexOf("^"));
        string child      = st.Substring(st.IndexOf("^") + 1, st.Length - st.IndexOf("^") - 1);

        MyDebugger.MyDebug("component " + entire_name + " parent " + parentName + " child " + child + " goType " + gOType);
        if (gOType == typeof(GameObject))
        {
            MyDebugger.MyDebug(gameObject.name + " is the GO");
            foreach (Component c in gameObject.GetComponents(typeof(MonoBehaviour)))
            {
                if (c.GetType().Name.Equals(parentName))
                {
                    MyDebugger.MyDebug("component " + c);
                    if (!child.Contains("^"))
                    {
                        MyDebugger.MyDebug(" of type " + c.GetType());
                        return(ReadSimpleProperty(child, c.GetType(), c));
                    }
                    else
                    {
                        return(ReadComposedProperty(gameObject, entire_name, child, c.GetType(), c, ReadSimpleProperty));
                    }
                }
            }
        }
        return(null);
    }
Esempio n. 2
0
    public static object ReadComposedProperty(GameObject gameObject, string entire_name, string st, Type objType, object obj, ReadSimpleProperty ReadSimpleProperty)
    {
        ////Debug.unityLogger.logEnabled = false;
        string parentName = st.Substring(0, st.IndexOf("^"));
        string child      = st.Substring(st.IndexOf("^") + 1, st.Length - st.IndexOf("^") - 1);

        MemberInfo[] members = objType.GetMember(parentName, SensorsUtility.BindingAttr);
        MyDebugger.MyDebug("members with name " + parentName + " " + members.Length);
        if (members.Length == 0)
        {
            return(ReadComponent(gameObject, entire_name, st, objType, obj, ReadSimpleProperty));
        }
        FieldOrProperty parentProperty = new FieldOrProperty(members[0]);
        ///MyDebugger.MyDebug(parentProperty.Name());
        object parent     = parentProperty.GetValue(obj);
        Type   parentType = parent.GetType();

        if (!child.Contains("^"))
        {
            return(ReadSimpleProperty(child, parentType, parent));
        }
        else
        {
            return(ReadComposedProperty(gameObject, entire_name, child, parentType, parent, ReadSimpleProperty));
        }
    }
Esempio n. 3
0
        private void LoadTools(GameState gameState)
        {
            String      toolSpritePath = "Sprites/Tools/";
            ToolFactory toolFactory    = new ToolFactory();

            foreach (ExistingTools et in Enum.GetValues(typeof(ExistingTools)))
            {
                Texture2D toolSprite = ContentManager.Load <Texture2D>(toolSpritePath + et.ToString());
                switch (et)
                {
                case ExistingTools.pickaxe:
                    Pickaxe.ToolSprite = toolSprite;
                    break;

                case ExistingTools.rope:
                    Rope.ToolSprite = toolSprite;
                    break;

                default:
                    MyDebugger.WriteLine(
                        string.Format("GameObject '{0}' cannot be created", true));
                    break;
                }

                Tool tool = toolFactory.Create(new Obj {
                    Type = et.ToString()
                });
                gameState.AddTool(et, tool);
            }
        }
Esempio n. 4
0
 private void CheckForAxisAsButtonInput(InputAxisAsButton input, string player, int controller)
 {
     if (Input.GetAxisRaw(input.MappableAxis + "Joy" + controller) == input.PressedValue)
     {
         MyDebugger.FormatDebug("PLAYER {0} {1} axis as button input read", player, input.name);
         // TODO: Trigger event
     }
 }
Esempio n. 5
0
 private void HandleMouse()
 {
     if (_mouseState.LeftButton == ButtonState.Pressed)
     {
         MyDebugger.Write("(" + _mouseState.Position.X + ", ", true);
         MyDebugger.WriteLine(_mouseState.Position.Y + ")", true);
     }
 }
Esempio n. 6
0
 protected void Start()
 {
     _pathGroup = new List <AStarPath>(GetComponentsInChildren <AStarPath>());
     if (Debugger)
     {
         _debugger = Debugger.GetComponent <MyDebugger>();
     }
 }
 public static IEnumerable <IMonoBehaviourSensor> GetSensors(Brain brain, object lockOn)
 {
     if (sensorsUpdatedCount(brain) != instantiatedSensorsCount(brain))
     {
         // MyDebugger.MyDebug("I'm waiting since " + sensorsUpdatedCount(brain) + "<>" + instantiatedSensorsCount(brain),brain.debug);
         MyDebugger.MyDebug(Thread.CurrentThread.Name + " is going to wait");
         Monitor.Wait(lockOn);
         MyDebugger.MyDebug(Thread.CurrentThread.Name + "is going to execute");
     }
     return(getInstantiatedSensors(brain));
 }
Esempio n. 8
0
    static void Main(string[] args)
    {
#if DEBUG
        MyDebugger.Test("../TextFile1.txt");
        //MyDebugger.Test("../TextFile2.txt");
        //TestCaseMaker.MakeTestCase1("../TextFile2.txt");
#else
        object ret = new Program().process(new StreamReader(Console.OpenStandardInput()));
        if (ret != null)
        {
            Console.WriteLine(ret);
        }
#endif
    }
    private void ReadSimpleListProperty(string path, Type type, object obj)
    {
        object[] listValue = SensorsUtility.GetListProperty(path, collectionElementProperty, type, obj, indexes[0]);
        if (listValue[0] != null && listValue[1] != null)
        {
            FieldOrProperty toRead = (FieldOrProperty)listValue[1];
            IList           list   = (IList)listValue[0];

            propertyValues.Add((T)Convert.ChangeType(toRead.GetValue(list[indexes[0]]), typeof(T)));
        }

        else
        {
            MyDebugger.MyDebug("Destroing " + path);
            SensorsManager.GetInstance().removeSensor(brain, this);
            Destroy(this);
            return;
        }
    }