Esempio n. 1
0
        private bool ObjectControlButtons(GameObject obj)
        {
            bool result = false;

            GUILayout.BeginHorizontal();
            {
                if (obj == SelectedObject)
                {
                    GUILayout.Label(obj.name);
                    if (GUILayout.Button($"{obj.name}({obj.GetType().Name})"))
                    {
                        result = true;
                    }
                }
                else
                {
                    if (GUILayout.Button($"{obj.name}({obj.GetType().Name})"))
                    {
                        result = true;
                    }
                }

                if (GUILayout.Button(obj.activeSelf ? "Disable" : "Enable"))
                {
                    obj.SetActive(!obj.activeSelf);
                }
            }
            GUILayout.EndHorizontal();
            return(result);
        }
Esempio n. 2
0
        //------------------------------------------------------------------------------------------------------------------------
        //														Add()
        //------------------------------------------------------------------------------------------------------------------------
        public void Add(GameObject gameObject)
        {
            MethodInfo info = gameObject.GetType().GetMethod("Update", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);

            if (info != null)
            {
                UpdateDelegate onUpdate = (UpdateDelegate)Delegate.CreateDelegate(typeof(UpdateDelegate), gameObject, info, false);
                if (onUpdate != null && !_updateReferences.ContainsKey(gameObject))
                {
                    _updateReferences[gameObject] = onUpdate;
                    _updateDelegates += onUpdate;
                }
            }
            else
            {
                validateCase(gameObject, "Update");
            }
            info = gameObject.GetType().GetMethod("LateUpdate", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
            if (info != null)
            {
                LateUpdateDelegate onLateUpdate = (LateUpdateDelegate)Delegate.CreateDelegate(typeof(LateUpdateDelegate), gameObject, info, false);
                if (onLateUpdate != null && !_lateUpdateReferences.ContainsKey(gameObject))
                {
                    _lateUpdateReferences[gameObject] = onLateUpdate;
                    _lateUpdateDelegates += onLateUpdate;
                }
            }
            else
            {
                validateCase(gameObject, "LateUpdate");
            }
        }
Esempio n. 3
0
        public GameObjectPool AddPoolForObject(GameObject prefabObject, ObjectPoolFullStrategy fullStrategy)
        {
            GameObjectPool gameObjectPool = null;

            if (prefabObject != null && prefabObject.GetType() != typeof(GameObjectPool) && prefabObject.GetType() != typeof(GameObjectPoolManager))
            {
                GameObject gameObject = new GameObject();
                gameObject.transform.parent = base.gameObject.transform;
                gameObjectPool = gameObject.AddComponent <GameObjectPool>();
                if (gameObjectPool != null)
                {
                    gameObjectPool.PrefabToInstance = prefabObject;
                    gameObjectPool.UpdatePoolName();
                }
                if (fullStrategy != null)
                {
                    gameObjectPool.FullStrategy = fullStrategy;
                }
                else
                {
                    gameObjectPool.FullStrategy = new DropObject();
                }
                UpdatePoolMapping();
            }
            else if (prefabObject == null)
            {
                Logger.LogFatal(this, "Cannot create a pool for null prefab!", Logger.TagFlags.CORE | Logger.TagFlags.MEMORY);
            }
            else
            {
                Logger.LogFatal(this, $"Cannot create a pool of type: {prefabObject.GetType()}", Logger.TagFlags.CORE | Logger.TagFlags.MEMORY);
            }
            return(gameObjectPool);
        }
Esempio n. 4
0
    public void ReturnItemToPool(GameObject item)
    {
        if (item.GetType() == Vehicle.GetType())
        {
            VehiclePool.RemoveItemFromUsedPool(item);
        }

        else if (item.GetType() == GroundTile.GetType())
        {
            GroundTilePool.RemoveItemFromUsedPool(item);
        }
        else if (item.GetType() == EndpointTile.GetType())
        {
            EndpointTilePool.RemoveItemFromUsedPool(item);
        }

        else if (item.GetType() == ConsumerBuilding.GetType())
        {
            ConsumerPool.RemoveItemFromUsedPool(item);
        }
        else if (item.GetType() == ProducerBuilding.GetType())
        {
            ProducerPool.RemoveItemFromUsedPool(item);
        }
    }
Esempio n. 5
0
        private static void GameObject_OnCreate(GameObject sender, EventArgs args)
        {
            if (!HasAnyOrbwalkerFlags)
            {
                return;
            }

            if (sender.GetType() == typeof(MissileClient))
            {
                var missile = sender as MissileClient;

                if ((missile != null) && missile.SpellCaster.IsMe)
                {
                    if (missile.SData.Name == "LucianWMissile")
                    {
                        Orbwalker.ResetAutoAttack();
                        return;
                    }
                }
            }

            if (sender.GetType() != typeof(Obj_GeneralParticleEmitter))
            {
                return;
            }

            var particle = sender as Obj_GeneralParticleEmitter;

            if ((particle == null) || !particle.Name.Contains("Lucian_Base_Q_laser") || (particle.Distance(Player.Instance) > 200))
            {
                return;
            }

            Orbwalker.ResetAutoAttack();
        }
Esempio n. 6
0
 private static void AddSavedType(GameObject gameObject)
 {
     if (!SavedTypes.Contains(gameObject.GetType().ToString()))
     {
         SavedTypes.Add(gameObject.GetType().ToString());
     }
 }
Esempio n. 7
0
        private static void GameObject_OnCreate(GameObject sender, EventArgs args)
        {
            if (!sender.IsValid || !sender.Name.Contains("Baron"))
                return;

            if (sender.Name.Contains("Minion") || sender.Name.Contains("_Turret_Cas.troy") || sender.Name.Contains("SRU") || sender.GetType().Name == "MissileClient" || sender.Name.Contains("FeelNoPain") || sender.Name.Contains("crystal_beam"))
                return;

            Console.WriteLine("Add\tType: {0} | Name: {1} | NetID: {2} | objectName: {3}", sender.GetType().Name, sender.Name, sender.NetworkId, sender.BaseObjectName());
        }
Esempio n. 8
0
 internal override void OnTouch(GameObject touchedObject)
 {
     if (touchedObject.GetType() == typeof(Marimo) && Marimo.IsStarMario((Marimo)touchedObject))
     {
         UpsideDownDeath();
     }
     else if (touchedObject.GetType() == typeof(Shell) && Shell.ShellIsMoving((Shell)touchedObject))
     {
         UpsideDownDeath();
     }
 }
Esempio n. 9
0
 private void DragObject(GameObject g)
 {
     if (g != null && (g.GetType().Equals(ObjectType) || g.GetType().IsSubclassOf(ObjectType)))
     {
         foreach (ObjectValue val in ReferenceValues)
         {
             val.set(g);
         }
         GetValueFromReferences();
     }
 }
Esempio n. 10
0
 public void AddToRoom(RoomBase room, GameObject objectToAdd)
 {
     if (objectToAdd.GetType().BaseType == typeof(Character) || objectToAdd.GetType() == typeof(Character))
     {
         objectToAdd.currentRoom = room;
         room.peoplePresent.Add((Character)objectToAdd);
     }
     else
     {
         room.contents.Add(objectToAdd.ObjectName, objectToAdd);
     }
 }
Esempio n. 11
0
        private static void GameObject_OnDelete(GameObject sender, EventArgs args)
        {
            if (!sender.IsValid || !sender.Name.Contains("Baron"))
                return;

            if (sender.Name.Contains("NAV") || sender.Name.Contains("Odin") || sender.Name.Contains("Shopkeeper") ||
                sender.GetType().Name == "MissileClient" || sender.GetType().Name == "DrawFX" || sender.Name.Contains("empty.troy") || sender.Name.Contains("LevelProp")
                 || sender.Name.Contains("FeelNoPain") || sender.Name.Contains("LaserSight") || sender.Name.Contains("SRU"))
                return;

            Console.WriteLine("Delete\tType: {0} | Name: {1}", sender.GetType().Name, sender.Name);
        }
Esempio n. 12
0
 // Creates a singleton, not working..
 public void MakeSingleton(System.Type type, GameObject obj)
 {
     if (type == null)
     {
         DontDestroyOnLoad(obj);
         type = obj.GetType();
     }
     else if (type != obj.GetType())
     {
         Destroy(obj);
     }
 }
Esempio n. 13
0
        private static Type GetPropertyTypeFromString(GameObject gameObj, string propertyPath)
        {
            if (propertyPath == "")
            {
                return(gameObj.GetType());
            }

            var propsQueue = new Queue <string>(propertyPath.Split('.').Where(s => !string.IsNullOrEmpty(s)));

            if (propsQueue == null)
            {
                throw new ArgumentException("Incorrent property path");
            }

            Type result;

            if (char.IsLower(propsQueue.Peek()[0]))
            {
                result = gameObj.GetType();
            }
            else
            {
                var component = gameObj.GetComponent(propsQueue.Dequeue());

                if (component == null)
                {
                    throw new ArgumentException("Incorrent property path");
                }

                result = component.GetType();
            }
            while (propsQueue.Count != 0)
            {
                var nameToFind = propsQueue.Dequeue();

                var property = result.GetProperty(nameToFind);
                if (property != null)
                {
                    result = property.PropertyType;
                }
                else
                {
                    var field = result.GetField(nameToFind);
                    if (field == null)
                    {
                        throw new ArgumentException("Incorrent property path");
                    }
                    result = field.FieldType;
                }
            }
            return(result);
        }
Esempio n. 14
0
 public void OnAdded(GameObject effectable)
 {
     foreach (var action in actions)
     {
         if (effectable.GetType() == action.Item1 || effectable.GetType().IsSubclassOf(action.Item1))
         {
             if (action.Item2 != null)
             {
                 action.Item2.Invoke(effectable);
             }
         }
     }
 }
Esempio n. 15
0
 public void OnUpdate(GameObject effectable)
 {
     foreach (var action in actions)
     {
         if (action.Item1.IsAssignableFrom(effectable.GetType()) || effectable.GetType() == action.Item1 || effectable.GetType().IsSubclassOf(action.Item1))
         {
             if (action.Item3 != null)
             {
                 action.Item3.Invoke(effectable);
             }
         }
     }
 }
Esempio n. 16
0
 public void Pack(GameObject gameObject)
 {
     if (gameObject.GetType() != typeof(Powerup))
     {
         throw new ArgumentException(
                   string.Format("Attempted to Pack {0} as {1}.",
                                 gameObject.GetType().ToString(),
                                 GetType().ToString()
                                 )
                   );
     }
     x       = gameObject.x;
     y       = gameObject.y;
     texture = gameObject.texture;
 }
Esempio n. 17
0
        public void Add(GameObject gameObject)
        {
            if (ObjectLimit.ContainsKey(gameObject.GetType()))
            {
                if (_gameObjects.Count(go => gameObject.GetType() == go.GetType()) >= ObjectLimit[gameObject.GetType()])
                {
                    return;
                }
            }

            if (!_gameObjects.Contains(gameObject) && !_addQueue.Contains(gameObject))
            {
                _addQueue.Add(gameObject);
            }
        }
Esempio n. 18
0
 public override void OnPlacedObject(GameObject pPlacedObject)
 {
     if (pPlacedObject.GetType() == typeof(X2DCamera))
     {
         mRenderingSystem.SetCamera((X2DCamera)pPlacedObject);
     }
     if (pPlacedObject.GetType() == typeof(X3DCamera))
     {
         mRenderingSystem.SetCamera((X3DCamera)pPlacedObject);
     }
     if (pPlacedObject.IsRenderable())
     {
         this.AddToScene(pPlacedObject.GetGraphicComponent());
     }
 }
Esempio n. 19
0
        private static void SpellMissile_ZedShadowDash(GameObject obj, EventArgs args)
        {
            if (obj.GetType() != typeof(MissileClient) || !((MissileClient)obj).IsValidMissile())
            {
                return;
            }

            MissileClient missile = (MissileClient)obj;

            if (missile.SpellCaster.IsEnemy && missile.SData.Name == "ZedWMissile")
            {
                if (!ObjectTracker.ObjTracker.ContainsKey(obj.NetworkId))
                {
                    ObjectTrackerInfo info = new ObjectTrackerInfo(obj);
                    info.Name           = "Shadow";
                    info.OwnerNetworkId = missile.SpellCaster.NetworkId;
                    info.UsePosition    = true;
                    info.Position       = missile.EndPosition;

                    ObjectTracker.ObjTracker.Add(obj.NetworkId, info);

                    DelayAction.Add(1000, () => ObjectTracker.ObjTracker.Remove(obj.NetworkId));
                }
            }
        }
        private static void OnCreate(GameObject sender, EventArgs args)
        {
#if DEBUG
            Console.WriteLine("Type: {0} | Name: {1}", sender.GetType().Name, sender.Name);
#endif
            foreach (var avoidObject in ObjectDatabase.AvoidObjects)
            {
                var baseObject = sender as Obj_AI_Base;
                var objectName = baseObject == null ? sender.Name : ObjectManager.Player.CharData.BaseSkinName;
                if (avoidObject.ObjectName == objectName)
                {
#if !DEBUG
                    if (!string.IsNullOrWhiteSpace(avoidObject.BuffName) && !sender.IsEnemy)
                    {
                        continue;
                    }
#endif
                    // Fire the event
                    if (OnAvoidObjectAdded != null)
                    {
                        OnAvoidObjectAdded(sender, avoidObject);
                    }
                    break;
                }
            }
        }
Esempio n. 21
0
        private static void OnCreateObj_FizzMarinerDoom(GameObject obj, EventArgs args, SpellData spellData)
        {
            if (obj.GetType() != typeof(MissileClient) || !((MissileClient) obj).IsValidMissile())
                return;

            MissileClient missile = (MissileClient)obj;

            if (missile.SpellCaster != null && missile.SpellCaster.Team != ObjectManager.Player.Team &&
                missile.SData.Name == "FizzMarinerDoomMissile")
            {
                SpellDetector.CreateSpellData(missile.SpellCaster, missile.StartPosition, missile.EndPosition,
                spellData, null, 500, true, SpellType.Circular, false, spellData.SecondaryRadius);

                /*foreach (KeyValuePair<int, Spell> entry in SpellDetector.spells)
                {
                    var spell = entry.Value;

                    if (spell.info.spellName == "FizzMarinerDoom" &&
                        spell.spellObject != null && spell.spellObject.NetworkId == missile.NetworkId)
                    {
                        if (spell.spellType == SpellType.Circular)
                        {                            
                            spell.spellObject = null;
                        }
                    }
                }*/
            }
        }
Esempio n. 22
0
 //------------------------------------------------------------------------------------------------------------------------
 //                                                        validateCase()
 //------------------------------------------------------------------------------------------------------------------------
 private void validateCase(GameObject gameObject)
 {
     MethodInfo info = gameObject.GetType().GetMethod("Update", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase);
     if (info != null) {
         throw new Exception("'Update' function was not binded for '" + gameObject + "'. Please check it's case. (capital U?)");
     }
 }
        public void OnCollide(GameObject other)
        {
            // Cancel if the enemy is currently spawning
            if (!enemy.IsSpawned)
            {
                return;
            }

            FrameworkDebug.LogCollision(DateTime.Now + ":" + DateTime.Now.Millisecond + " " + enemy.GetType().Name +
                                        " collision with " + other.GetType().Name);

            switch (other)
            {
            case AbstractEnemy _:
                // Get if there is a no overlap component
                var hasNoOverlap = other.GetComponents <CollisionComponent>().Aggregate(false, (b, component) =>
                                                                                        b || component is EnemyNoOverlapCollisionController);
                // Enemies should not overlap if the component is present
                if (hasNoOverlap)
                {
                    GetComponent <ColliderComponent>().UndoOverlap(other.GetComponent <ColliderComponent>());
                }
                break;
            }
        }
Esempio n. 24
0
        public void OnCollide(GameObject other)
        {
            // OVERKILL avoidance:
            // Avoid duplicate shots hit the enemy and when the enemy is spawning it shell not get killed
            if (!enemy.IsAlive || !enemy.IsSpawned)
            {
                return;
            }

            FrameworkDebug.LogCollision(DateTime.Now + ":" + DateTime.Now.Millisecond + " " + enemy.GetType().Name +
                                        " collision with " + other.GetType().Name);

            switch (other)
            {
            case Shot.Shot shot:
                shot.OwningPlayer.Attributes.OnEnemyKill(enemy);

                // Destroy the shot and spawn the explosion
                Scene.Current.Spawn(new EnemyExplosionParticleEmitterObject(GameObject as AbstractEnemy));
                Scene.Current.Destroy(GameObject);

                // For now, destroy also the shot (could also have an explosion like effect)
                Scene.Current.Destroy(shot);
                break;
            }
        }
Esempio n. 25
0
        public override void Execute()
        {
            GameObject obj = GameObjectManager.FindGameObject(gameObjectID);

            if (obj != null && componentID != "None")
            {
                ObjectComponent comp = obj.FindComponent(componentID);

                if (comp != null)
                {
                    Type         t    = comp.GetType();
                    PropertyInfo prop = t.GetProperty(propertyName);

                    if (prop != null && prop.PropertyType == value.GetType())
                    {
                        prop.SetValue(comp, value, null);
                    }
                }
            }
            else if (obj != null)
            {
                Type         t    = obj.GetType();
                PropertyInfo prop = t.GetProperty(propertyName);

                if (prop != null && prop.PropertyType == value.GetType())
                {
                    prop.SetValue(obj, value, null);
                }
            }

            FinishExecution();
        }
Esempio n. 26
0
 internal override void OnTouch(GameObject touchedObject)
 {
     if (touchedObject.GetType().Name == "Fireball")
     {
         UpsideDownDeath();
         FireballExplode((Fireball)touchedObject);
     }
     else if (touchedObject.GetType() == typeof(Marimo) && Marimo.IsStarMario((Marimo)touchedObject))
     {
         UpsideDownDeath();
     }
     else if (touchedObject.GetType().Name == "Shell" && Shell.ShellIsMoving((Shell)touchedObject))
     {
         UpsideDownDeath();
     }
 }
Esempio n. 27
0
        private void MouseRight()
        {
            if (InputHelper.MouseRightDown)
            {
                if (gameScreen.Rectangle.Contains(InputHelper.MousePosition))
                {
                    Vector2    position   = new Vector2((int)(InputHelper.MousePositionInWorld.X / 32f) * 32, (int)(InputHelper.MousePositionInWorld.Y / 32f) * 32);
                    GameObject gameObject = gameScreen.LevelData.GameObjects.OrderByDescending(x => x.ZIndex).FirstOrDefault(x => x.Position == position);
                    if (gameObject != null)
                    {
                        deletingType = gameObject.GetType();
                    }
                }
            }

            if (InputHelper.MouseRight)
            {
                if (gameScreen.Rectangle.Contains(InputHelper.MousePosition))
                {
                    Vector2    position   = new Vector2((int)(InputHelper.MousePositionInWorld.X / 32f) * 32, (int)(InputHelper.MousePositionInWorld.Y / 32f) * 32);
                    GameObject gameObject = gameScreen.LevelData.GameObjects.FirstOrDefault(x => x.Position == position && x.GetType() == deletingType);
                    if (gameObject != null)
                    {
                        gameScreen.LevelData.GameObjects.Remove(gameObject);
                    }
                }
            }
        }
Esempio n. 28
0
    public static T GetCopyOf <T>(this GameObject comp, T other) where T : Component
    {
        Type type = comp.GetType();

        if (type != other.GetType())
        {
            return(null);                         // type mis-match
        }
        BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Default | BindingFlags.DeclaredOnly;

        PropertyInfo[] pinfos = type.GetProperties(flags);
        foreach (var pinfo in pinfos)
        {
            if (pinfo.CanWrite)
            {
                try
                {
                    pinfo.SetValue(comp, pinfo.GetValue(other, null), null);
                }
                catch { } // In case of NotImplementedException being thrown. For some reason specifying that exception didn't seem to catch it, so I didn't catch anything specific.
            }
        }
        FieldInfo[] finfos = type.GetFields(flags);
        foreach (var finfo in finfos)
        {
            finfo.SetValue(comp, finfo.GetValue(other));
        }
        return(comp as T);
    }
Esempio n. 29
0
        private void MouseLeft()
        {
            foreach (GameObject go in gameObjects)
            {
                if (InputHelper.MouseLeft)
                {
                    if (go.Rectangle.Contains(new Vector2(InputHelper.MousePosition.X - Rectangle.X, InputHelper.MousePosition.Y)))
                    {
                        selectedGameObject = go;
                    }

                    if (gameScreen.Rectangle.Contains(InputHelper.MousePosition))
                    {
                        Vector2    position   = new Vector2((int)(InputHelper.MousePositionInWorld.X / 32f) * 32, (int)(InputHelper.MousePositionInWorld.Y / 32f) * 32);
                        GameObject gameObject = gameScreen.LevelData.GameObjects.FirstOrDefault(x => x.Position == position && x.ZIndex == selectedGameObject.ZIndex);
                        if (gameObject == null)
                        {
                            gameScreen.LevelData.CreateGameObject((GameObject)Activator.CreateInstance(selectedGameObject.GetType()), position);
                        }
                        else
                        {
                            if (gameObject.GetType() != go.GetType())
                            {
                                if (gameObject != null)
                                {
                                    gameScreen.LevelData.GameObjects.Remove(gameObject);
                                }
                                gameScreen.LevelData.CreateGameObject((GameObject)Activator.CreateInstance(selectedGameObject.GetType()), position);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 30
0
        public override void Execute()
        {
            GameObject obj = GameObjectManager.FindGameObject(gameObjectID);

            if (obj != null && componentID != "None")
            {
                ObjectComponent comp = obj.FindComponent(componentID);

                if (comp != null)
                {
                    Type       t    = comp.GetType();
                    MethodInfo info = t.GetMethod(methodName);

                    if (info != null)
                    {
                        info.Invoke(comp, parameters);
                    }
                }
            }
            else if (obj != null)
            {
                Type       t    = obj.GetType();
                MethodInfo info = t.GetMethod(methodName);

                if (info != null)
                {
                    info.Invoke(obj, parameters);
                }
            }

            FinishExecution();
        }
Esempio n. 31
0
 private void CheckForInput(GameObject gameObject, List <InputCommand> inputCommands)
 {
     foreach (InputCommand ic in inputCommands)
     {
         if (ic.isDown)
         {
             if (gameObject.identity.name.Equals(ic.objectName))
             {
                 MethodInfo method = gameObject.GetType().GetMethod(ic.methodName);
                 if (ic.thumbstick)
                 {
                     method.Invoke(gameObject, DynamicArray.ObjectArray(ic.parameters, ic.magnitude));
                 }
                 else
                 {
                     method.Invoke(gameObject, ic.parameters);
                 }
             }
             else if (ic.objectName.Equals("Camera"))
             {
                 MethodInfo method = GameManager.game.GetCameraManager().GetType().GetMethod(ic.methodName);
                 method.Invoke(GameManager.game.GetCameraManager(), ic.parameters);
             }
             else if (ic.objectName.Equals("Game"))
             {
                 MethodInfo method = GameManager.game.GetType().GetMethod(ic.methodName);
                 method.Invoke(GameManager.game, ic.parameters);
             }
         }
     }
 }
Esempio n. 32
0
    public bool ReturnPool(int index, GameObject L_object)//인덱스를 제거후 instanceID로 찾고 반환
    {
        if (ArrayPool.Length() > index)
        {
            if (ArrayPool.Get(index).m_Preperb.GetType() == L_object.GetType() && L_object.activeSelf)
            {
                ArrayPool.Get(index).PoolObject.Enqueue(L_object);
                L_object.transform.position = Vector3.zero;
                L_object.transform.rotation = Quaternion.identity;
                L_object.SetActive(false);

                //ArrayPool.Get(index).ActivePoolObj--;
                ArrayPool.Get(index).Add_ActivePool(-1);

                {
                    if (SaveActiveObj)
                    {
                        ArrayPool.Get(index).ActivePoolObj.Remove(L_object);
                    }
                }//Remove ActivePoolObject
                return(true);
            }
            else
            {
                return(false);
            }
        }
        else
        {
            return(false);
        }
    }
Esempio n. 33
0
    static void RefreshBehaviourTypes()
    {
        if (!goToUse)
        {
            return;
        }

        //get all components on game object we are using
        var comps = goToUse.GetComponents <Component>();

        //create type list on source for accessing all types including gameobject
        behaviourTypes = new System.Type[comps.Length + 1];
        if (behaviourTypes.Length > 0)
        {
            for (int i = 0; i < behaviourTypes.Length; i++)
            {
                //store gameobject as first type
                if (i == 0)
                {
                    behaviourTypes[i] = goToUse.GetType();
                }
                //get rest of component types attached to gameobject
                else
                {
                    behaviourTypes[i] = comps[i - 1].GetType();
                }
            }
        }
    }
Esempio n. 34
0
 public void InflictDamageBy(float damage, bool explosion, GameObject source, GameObject by)
 {
     if (projectiles.Any(p => p.GetType() == by.GetType()))
     {
         base.InflictDamage(damage, explosion, source);
     }
 }
Esempio n. 35
0
 private static void OnCreate(GameObject sender, EventArgs args)
 {
     #if DEBUG
     Console.WriteLine("Type: {0} | Name: {1}", sender.GetType().Name, sender.Name);
     #endif
     foreach (var avoidObject in ObjectDatabase.AvoidObjects)
     {
         var baseObject = sender as Obj_AI_Base;
         var objectName = baseObject == null ? sender.Name : baseObject.BaseSkinName;
         if (avoidObject.ObjectName == objectName)
         {
     #if !DEBUG
             if (!string.IsNullOrWhiteSpace(avoidObject.BuffName) && !sender.IsEnemy)
             {
                 continue;
             }
     #endif
             // Fire the event
             if (OnAvoidObjectAdded != null)
             {
                 OnAvoidObjectAdded(sender, avoidObject);
             }
             break;
         }
     }
 }
Esempio n. 36
0
        internal static void DrawTypeIcon(Rect position, GameObject obj, GrendelFolderComponent folderComponent)
        {
            GUIContent customIcon = new GUIContent();
            GUIContent typeIcon   = new GUIContent();

            bool  hasCustomIcon    = false;
            Color previousGUIColor = GUI.color;

            customIcon = new GUIContent(EditorGUIUtility.ObjectContent(obj, obj.GetType()));

            if (folderComponent == null)
            {
                typeIcon = new GUIContent(EditorGUIUtility.ObjectContent(null, TryGetFirstNonTransformComponentType(obj.GetComponents <Component>())));

                hasCustomIcon = (customIcon.image != sGameObjectIcon.image) &&
                                (customIcon.image != sPrefabIcon.image) &&
                                (customIcon.image != sPrefabModelIcon.image) &&
                                (customIcon.image != sPrefabNormalIcon.image);
            }
            else
            {
                Color folderColor = folderComponent.FolderColor;
                folderColor.a = 1f;
                GUI.color     = Color.Lerp(GUI.color, folderColor, folderComponent.FolderColor.a);
                typeIcon      = new GUIContent(GrendelEditorIcons.FolderIcon);
            }

            GUI.Label(position, hasCustomIcon ? customIcon.image : typeIcon.image, sCustomIconStyle);
            GUI.color = previousGUIColor;
        }
Esempio n. 37
0
        private string GetTypeString(GameObject obj)
        {
            string       typeString = "";
            Queue <Type> toDo       = new Queue <Type>();
            List <Type>  result     = new List <Type>();

            toDo.Enqueue(obj.GetType());
            while (toDo.Count > 0)
            {
                Type        type   = toDo.Dequeue();
                List <Type> dTypes = new List <Type>();
                if (derivedTypes.TryGetValue(type, out dTypes))
                {
                    foreach (Type t in dTypes)
                    {
                        if (!result.Contains(t))
                        {
                            toDo.Enqueue(t);
                            result.Add(t);
                        }
                    }
                }
            }

            foreach (Type t in result)
            {
                if (typeString != "")
                {
                    typeString += "=>";
                }
                typeString += t.ToString();
            }

            return(typeString);
        }
Esempio n. 38
0
 internal override void OnTouch(GameObject touchedObject)
 {
     if (touchedObject.GetType().Name == "Marimo")
     {
         shouldRemove = true;
         Player.AddPoints(points);
     }
 }
Esempio n. 39
0
        public static string CheckType(GameObject obj)
        {
            if (obj.GetType() == typeof(BulletBill))
            {
                return "BulletBill";
            }
            if (obj.GetType() == typeof(Goomba))
            {
                return "Goomba";
            }
            if (obj.GetType() == typeof(KoopaGreen))
            {
                return "KoopaGreen";
            }

            return "GameObject";
        }
Esempio n. 40
0
 public override void OnSideCollision(GameObject touchedObject)
 {
     if (touchedObject.GetType().Namespace == "SuperMarimoBros.Blocks")
     {
         Explode();
     }
     base.OnSideCollision(touchedObject);
 }
Esempio n. 41
0
 public override void OnSideCollision(GameObject touchedObject)
 {
     if (touchedObject.GetType().Name == "Marimo")
     {
         Kick(touchedObject);
     }
     else
         base.OnSideCollision(touchedObject);
 }
Esempio n. 42
0
 public override void OnHeadbutt(GameObject touchedObject)
 {
     if (touchedObject.GetType() == typeof(Marimo))
     {
         this.shouldRemove = true;
         World.AddObject(new Shell(position, false));
     }
     base.OnHeadbutt(touchedObject);
 }
Esempio n. 43
0
 public override void OnHeadbutt(GameObject touchedObject)
 {
     if (touchedObject.GetType().Name == "Marimo")
     {
         wasStomped = true;
         Player.AddPoints(points);
     }
     base.OnHeadbutt(touchedObject);
 }
Esempio n. 44
0
 internal override void OnTouch(GameObject touchedObject)
 {
     if (touchedObject.GetType() == typeof(Marimo))
     {
         Player.AddCoin();
         shouldRemove = true;
     }
     base.OnTouch(touchedObject);
 }
Esempio n. 45
0
        public override void OnStomp(GameObject touchedObject)
        {
            if (touchedObject.GetType().Namespace == "SuperMarimoBros.Blocks")
            {
                velocity.Y = -150f;
            }

            base.OnStomp(touchedObject);
            isOnSolidTile = false;
        }
Esempio n. 46
0
 public override void OnHit(GameObject obj)
 {
     if(IsActive())
     {
         if (obj.GetType() == typeof(SimpleBulet))
         {
             var ite = obj as SimpleBulet;
             ite.Hp = 0;
         }
         if (obj.GetType() == typeof(SimpleShip))
         {
             var ite = obj as SimpleShip;
             ite.Hp = 0;
         }
         if (obj.GetType() == typeof(SimpleShield))
         {
             var ite = obj as SimpleShield;
         }
     }
 }
Esempio n. 47
0
 void Generate()
 {
     if(numLeft > 0) {
         current = GameObject.Instantiate(blockProto, Vector3.zero, Quaternion.identity) as GameObject;
         Debug.Log (current.ToString());
         Debug.Log (current.GetType ().ToString());
         current.transform.SetParent (gameObject.transform);
         current.transform.localPosition = new Vector3(0.6f, 0, 0);
         current.transform.localScale = new Vector3(1, 1, 1);
         current.GetComponent<ProgBlock>().onPickup += OnPickup;
     }
 }
Esempio n. 48
0
		//------------------------------------------------------------------------------------------------------------------------
		//														Add()
		//------------------------------------------------------------------------------------------------------------------------
		public void Add(GameObject gameObject) {
			MethodInfo info = gameObject.GetType().GetMethod("Update", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
			if (info != null) {
				UpdateDelegate onUpdate = (UpdateDelegate)Delegate.CreateDelegate(typeof(UpdateDelegate), gameObject, info, false);
				if (onUpdate != null && !_updateReferences.ContainsKey(gameObject)) {
					_updateReferences[gameObject] = onUpdate;
					_updateDelegates += onUpdate;
				}
			} else {
				validateCase(gameObject);
			}
		}
Esempio n. 49
0
    public override void HandleHeadCollision(GameObject other)
    {
        Debug.Log("Head Collide check against " + other.GetType().Name);
        GameObjectProperties props = (GameObjectProperties)other.GetComponent("GameObjectProperties");

        if (props != null)
        {
            if (props.isPlayer)
            {
                Player player = (Player)other.GetComponent("Player");
                player.Die();
            }
            if (props.isLethal)
            {
                manager.InformDeath(this);
            }
        }
        else
        {
            Debug.Log("Head Cannot collide with " + other.GetType().Name + ", no properties");
        }
    }
Esempio n. 50
0
 public override void OnHeadbutt(GameObject touchedObject)
 {
     if (touchedObject.GetType().Name == "Marimo")
     {
         if (velocity.X == 0)
         {
             Kick(touchedObject);
         }
         else
         {
             velocity.X = 0;
         }
     }
 }
        public static void CreatePrefab(GameObject asset) {
            string path = AssetDatabase.GetAssetPath(Selection.activeObject);
            if (path == "") {
                path = "Assets";
            }
            else if (Path.GetExtension(path) != "") {
                path = path.Replace(Path.GetFileName(AssetDatabase.GetAssetPath(Selection.activeObject)), "");
            }

            string assetPathAndName = AssetDatabase.GenerateUniqueAssetPath(path + "/New " + asset.GetType().ToString() + ".prefab");

            var prefab = PrefabUtility.CreateEmptyPrefab(assetPathAndName);
            PrefabUtility.ReplacePrefab(asset, prefab, ReplacePrefabOptions.ConnectToPrefab);

            Selection.activeObject = asset;
        }
Esempio n. 52
0
        private static void OnDeleteObj_FizzMarinerDoom(GameObject obj, EventArgs args, SpellData spellData)
        {
            //need to track where bait is attached to

            if (obj.GetType() != typeof(MissileClient) || !((MissileClient) obj).IsValidMissile())
                return;

            MissileClient missile = (MissileClient)obj;

            if (missile.SpellCaster != null && missile.SpellCaster.Team != ObjectManager.Player.Team &&
                missile.SData.Name == "FizzMarinerDoomMissile")
            {
                SpellDetector.CreateSpellData(missile.SpellCaster, missile.StartPosition, missile.EndPosition,
                spellData, null, 1000, true, SpellType.Circular, false, 350);
            }
        }
Esempio n. 53
0
        public static SimDescription ReturnCreaotrSimDescription(GameObject craftedObject)
        {
            Type t = craftedObject.GetType();

            // StyledNotification.Show(new StyledNotification.Format("Type: " + t.BaseType.ToString(), StyledNotification.NotificationStyle.kGameMessagePositive));


            if (t == typeof(PreparedFood))
            {
                return SimDescription.Find(((PreparedFood)craftedObject).CookingProcess.Preparer.SimDescriptionId);
            }

            if (t == typeof(Fish))
            {
                return ((Fish)craftedObject).FishingSim;
            }
            if (t == typeof(NectarBottle))
            {
                return ((NectarBottle)craftedObject).Creator;
            }

            if (t == typeof(Photograph))
            {
                return ((Photograph)craftedObject).Artist;
            }

            if (t == typeof(Sculpture))
            {
                return ((Sculpture)craftedObject).SculptureComponent.Artist;
            }

            //If an invention            
            Widget wid = craftedObject as Widget;
            if (wid != null)
            {
                return wid.Inventor;
            }

            Invention inv = craftedObject as Invention;
            if (inv != null)
            {
                return inv.Inventor;
            }

            return null;
        }
 /// <summary>
 /// destroys the given object and moves the corresponding object to the former's position.
 /// </summary>
 private void moveObject(GameObject initialObj, string sharedTag)
 {
     if (initialObj.tag == "appearable")
     {
         Object[] objects = FindObjectsOfType(initialObj.GetType());
         for (int i = 0; i < objects.Length; i++)
         {
             GameObject temp = (GameObject)objects[i];
             if (temp.tag == "appearable")
             {
                 temp.transform.position = initialObj.transform.position;
                 //Object being moved can't have a collider.
                 //Duplicate object, change tag to "Untagged", turn on Collider, turn off Mesh Renderer
             }
         }
         Destroy(initialObj);
     }
 }
        //------------------------------------------------------------------------------------------------------------------------
        //                                                        Add()
        //------------------------------------------------------------------------------------------------------------------------
        public void Add(GameObject gameObject)
        {
            if (gameObject.collider != null && !colliderList.Contains (gameObject)) {
                colliderList.Add(gameObject);
            }

            MethodInfo info = gameObject.GetType().GetMethod("OnCollision", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);

            if (info != null) {

                CollisionDelegate onCollision = (CollisionDelegate)Delegate.CreateDelegate(typeof(CollisionDelegate), gameObject, info, false);
                if (onCollision != null && !_collisionReferences.ContainsKey (gameObject)) {
                    ColliderInfo colliderInfo = new ColliderInfo(gameObject, onCollision);
                    _collisionReferences[gameObject] = colliderInfo;
                    activeColliderList.Add(colliderInfo);
                }

            } else {
                validateCase(gameObject);
            }
        }
Esempio n. 56
0
        private static void OnCreateObj_ViktorDeathRay3(GameObject obj, EventArgs args)
        {
            if (obj.GetType() != typeof(MissileClient) || !((MissileClient) obj).IsValidMissile())
                return;

            MissileClient missile = (MissileClient)obj;

            SpellData spellData;

            if (missile.SpellCaster != null && missile.SpellCaster.Team != ObjectManager.Player.Team &&
                missile.SData.Name != null && missile.SData.Name == "viktoreaugmissile"
                && SpellDetector.onMissileSpells.TryGetValue("ViktorDeathRay3", out spellData)
                && missile.StartPosition != null && missile.EndPosition != null)
            {
                var missileDist = missile.EndPosition.To2D().Distance(missile.StartPosition.To2D());
                var delay = missileDist / 1.5f + 600;

                spellData.spellDelay = delay;

                SpellDetector.CreateSpellData(missile.SpellCaster, missile.StartPosition, missile.EndPosition, spellData);
            }
        }
        public GameObjectDiagnosis(GameObject obj, StreamWriter writer = null, string fileLocation = null)
        {
            Handle = obj;
            FileLocation = writer == null ? Path.Combine(Environment.CurrentDirectory, string.Format("single_diagnosis_{0}.txt", SingleDiagnosisCount++)) : null;
            Writer = writer ?? File.CreateText(fileLocation ?? FileLocation);
            DisposeWriter = writer == null;

            if (Handle == null)
            {
                WriteLine("Handle is null!");
                Flush();
                throw new ArgumentNullException("obj");
            }

            // Create header
            WriteLine("------------------------------------------------------------------------------------------------");
            WriteLine("Analyzing GameObject of System.Type: {0}", Handle.GetType().Name);
            Write("GameObjectType: ");
            Flush();
            WriteLine(Handle.Type);
            WriteLine("Beginning recursive diagnosis of the properties...");
            WriteLine();
        }
Esempio n. 58
0
        private static void SpellMissile_ZedShadowDash(GameObject obj, EventArgs args)
        {
            if (obj.GetType() != typeof(MissileClient) || !((MissileClient) obj).IsValidMissile())
                return;

            MissileClient missile = (MissileClient)obj;

            if (missile.SpellCaster.IsEnemy && missile.SData.Name == "ZedWMissile")
            {
                if (!ObjectTracker.ObjTracker.ContainsKey(obj.NetworkId))
                {
                    ObjectTrackerInfo info = new ObjectTrackerInfo(obj);
                    info.Name = "Shadow";
                    info.OwnerNetworkId = missile.SpellCaster.NetworkId;
                    info.UsePosition = true;
                    info.Position = missile.EndPosition;

                    ObjectTracker.ObjTracker.Add(obj.NetworkId, info);

                    DelayAction.Add(1000, () => ObjectTracker.ObjTracker.Remove(obj.NetworkId));
                }
            }
        }
Esempio n. 59
0
        private static void Verify(GameObject sender, EventArgs args, string eventName, bool recursiveSender = false, bool recursiveArgs = true)
        {
            if (!Directory.Exists(Program.ResultPath))
            {
                Directory.CreateDirectory(Program.ResultPath);
            }

            using (var writer = File.CreateText(Path.Combine(Program.ResultPath, eventName + ".txt")))
            {
                using (var analyzer = new GameObjectDiagnosis(sender, writer))
                {
                    var stopwatch = new Stopwatch();
                    stopwatch.Start();
                    analyzer.Analyze(sender, true, recursiveSender);
                    analyzer.Analyze(args, false, recursiveArgs);
                    stopwatch.Stop();
                    Logger.Log(LogLevel.Debug, "Total analyze time of {0}<{2}> (including disk IO): {1}ms", eventName, stopwatch.ElapsedTicks / (double) TimeSpan.TicksPerMillisecond,
                        sender.GetType().Name);

                    var times = analyzer.ComputeTimes.OrderByDescending(o => o.Key).ToArray();
                    if (times.Length > 0)
                    {
                        writer.WriteLine();
                        writer.WriteLine();
                        writer.WriteLine("Top {0} compute times:", Math.Min(10, times.Length));
                        for (var i = 0; i < Math.Min(10, times.Length); i++)
                        {
                            writer.WriteLine(" - {0}: {1}ms", times[i].Value, times[i].Key);
                        }
                    }
                }
            }
        }
Esempio n. 60
0
    void OnGUI()
    {
        //"transform.rotation.x" "directionLight.intesity"
                //LambdaExpression lmb;
                //lmb.Compile().Method.I

                animatedObject = EditorGUILayout.ObjectField (animatedObject, typeof(GameObject), true) as GameObject;
                clip = EditorGUILayout.ObjectField (clip, typeof(AnimationClip), true) as AnimationClip;

                animatedObject1 = EditorGUILayout.ObjectField (animatedObject1, typeof(GameObject), true) as GameObject;
                clip1 = EditorGUILayout.ObjectField (clip1, typeof(AnimationClip), true) as AnimationClip;

                //

            AnimatorController aniController;
        //AnimatorController.

        //CREATE NEW MOVIE CLIP

        //		private static AnimationClip GenerateTriggerableTransition(string name, AnimatorController controller)
        //		{
        //			AnimationClip animationClip = AnimatorController.AllocateAnimatorClip(name);
        //			AssetDatabase.AddObjectToAsset(animationClip, controller);
        //			State dst = AnimatorController.AddAnimationClipToController(controller, animationClip);
        //			controller.AddParameter(name, AnimatorControllerParameterType.Trigger);
        //			StateMachine stateMachine = controller.GetLayer(0).stateMachine;
        //			Transition transition = stateMachine.AddAnyStateTransition(dst);
        //			AnimatorCondition condition = transition.GetCondition(0);
        //			condition.mode = TransitionConditionMode.If;
        //			condition.parameter = name;
        //
        //			return animationClip;
        //		}

        //		public static AnimationClip AllocateAnimatorClip (string name)
        //		{
        //			AnimationClip animationClip = AnimationSelection.AllocateAndSetupClip (true);
        //			animationClip.name = name;
        //			return animationClip;
        //		}

        //Create CONTROLER AT
        //AnimatorController.CreateAnimatorControllerAtPath(text4);
        //AnimatorController.CreateAnimatorControllerAtPathWithClip (path,clip);

                if (GUILayout.Button ("Test")) {

        //			Type newType=typeof(MemberDelegate<>).MakeGenericType (new Type[] {
        //				typeof(int)
        //			});
        //
        //			var dlgate = Delegate.CreateDelegate(newType,this.GetType().GetMethod("Foo"));

                        //Foo1(dlgate,123);

                        //object instance=animatedObject1.transform.rotation;
                        Transform transformInstance = animatedObject1.transform;
                        object transformObject = animatedObject1.transform;

        //						MemberInfo infoX =  typeof(Transform).GetMemberFromPath ("rotation.x");
        //						MemberInfo infoMember = typeof(SomeTypeClass).GetField ("member");
        //						MemberInfo infoMemberStatic = typeof(SomeTypeClass).GetField ("memberStatic", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public);
        //						MemberInfo infoProp = typeof(SomeTypeClass).GetProperty ("Getter");
                        SomeTypeClass cls = new SomeTypeClass ();

                        var s1 = cls.GetType ().GetSetDelegate ("memberStatic");
                        object clsObject = cls;
                        s1 (ref clsObject, 101);

                        var s2 = cls.GetType ().GetSetDelegate ("memberStructStatic");
                        s2 (ref clsObject, new Vector3 (3f, 33f, 333f));

                        var s3 = cls.GetType ().GetSetDelegate ("memberStruct");
                        s3 (ref clsObject, new Vector3 (3f, 33f, 333f));

                        Quaternion q = Quaternion.identity;//Quaternion.Euler(25f,170f,14f);
                        object qObject = Quaternion.identity;//Quaternion.Euler(25f,170f,14f);

                        //object transformObject;//=animatedObject1.GetType().GetMember("transform")[0].GetValue(animatedObject1);
                        //
                        UnityEngine.Object gameObject = animatedObject1;

                        //var so=CreateSetMethod(animatedObject1.GetType().GetMemberFromPath("transform.rotation"));

                        //so(ref transformObject,new Quaternion(0f,1f,0f,0f));

        //			var so=CreateSetMethod(animatedObject1.GetType().GetMemberFromPath("transform.rotation.x"));
        //
        //			so(ref qObject,0.16f);

                        //get component

                        var transformGetterDelegate = animatedObject1.GetType ().GetGetDelegate ("transform");
        //
        //
        //
        //
        //			//get prop1
                        var quaternionGetDelegate = animatedObject1.GetType ().GetGetDelegate ("transform.rotation");
                        var quaternionSetDelegate = animatedObject1.GetType ().GetSetDelegate ("transform.rotation");

        //			var mdfdf=animatedObject1.GetType().GetMemberFromPath("transform.rotation").GetSetMemberInfoDelegate<Transform,Quaternion>();
        //			mdfdf(ref transformInstance,q);

        //			var mdfdf=animatedObject1.GetType().GetMemberFromPath("transform.rotation").GetSetMemberInfoDelegate<object,object>();
        //			mdfdf(ref transformObject,q);

                        var mdfdf = animatedObject1.GetType ().GetMemberFromPath ("transform.rotation.x").GetSetMemberInfoDelegate<object,object> ();
                        mdfdf (ref qObject, 0.5f);

        //			var mdfdf=animatedObject1.GetType().GetMemberFromPath("transform.rotation.x").GetSetMemberInfoDelegate<Quaternion,float>();
        //			mdfdf(ref q,0.3f);

                        //			//get prop2
                        var xGetter = typeof(Transform).GetGetDelegate ("rotation.x");

                        var xSetter = typeof(Transform).GetSetDelegate ("rotation.x");

                        object transfromObject = transformGetterDelegate (gameObject);

        //			object xOut=xGetter(quaternionGetDelegate(transformGetterDelegate(gameObject)));
        //
        //			object quaternionObject=quaternionGetDelegate(transformGetterDelegate(gameObject));
        //
        //			xSetter(ref quaternionObject,1.5f);
        //
        //			quaternionSetDelegate(ref transfromObject,quaternionObject);

                        ////setter(ref a,20);

                        //setter(instance,0.7f);
                        //Action a=CreateSetMethod(info)

                        //a(ref instance,34f);
                        Debug.Log ("q: " + q);
                        Debug.Log ("qObject: " + qObject);
                        Debug.Log ("animatedObject " + animatedObject1.transform.rotation);
        //						Debug.Log ("Field 'member'" + cls.member);
        //						Debug.Log ("Property 'Getter'" + cls.Getter);
                        Debug.Log ("Property 'memberStruct'" + cls.memberStruct);
                        Debug.Log ("Static :" + SomeTypeClass.memberStructStatic);
                        Debug.Log ("Static :" + SomeTypeClass.memberStatic);
        //						Debug.Log ("rotation.x set:" + animatedObject1.transform.rotation.x);

                        //Debug.Log("result="+result+" "+q);
                }

                if (clip != null && animatedObject != null) {
                        if (GUILayout.Button ("Save Curves")) {

                                EditorCurveBinding[] curveBindings = AnimationUtility.GetCurveBindings (clip);

                                int curveBindingLen = curveBindings.Length;
                                curves = new AnimationCurve[curveBindingLen];
                                variables = new UnityVariable[curveBindingLen];
                                String propertyName = null;
                                EditorCurveBinding curveBindingCurrent;
                                UnityVariable variableCurrent;
                                for (int num = 0; num < curveBindingLen; num++) {
                                        curveBindingCurrent = curveBindings [num];

                                        UnityEngine.Object instance = AnimationUtility.GetAnimatedObject (animatedObject, curveBindingCurrent);
                                        if (instance != null) {

                                                curves [num] = AnimationUtility.GetEditorCurve (clip, curveBindingCurrent);

                                                propertyName = curveBindingCurrent.propertyName;
                                                //process "m_Rotation.x" "m_Intensity" into "rotation.x", "intensity"
                                                propertyName = char.ToLower (propertyName [2]) + propertyName.Remove (0, 3);

                                                Type type = curveBindingCurrent.type.GetMemberFromPath (propertyName).GetUnderlyingType ();

                                                variableCurrent = variables [num] = UnityVariable.CreateInstanceOf (type);

                                                //ex. Transform or Light component
                                                var instanceToBind = instance.GetType () == typeof(GameObject) ? ((GameObject)instance).transform : instance;

                                                variableCurrent.Bind (instanceToBind, propertyName);

                                        } else {

                                                Debug.LogWarning (curveBindingCurrent.propertyName + " not found in " + animatedObject);
                                        }

                                        Debug.Log ("i:" + instance.name + " path " + curveBindingCurrent.path + " prop:" + curveBindingCurrent.propertyName + " t:" + curveBindingCurrent.type
                                        );
                                }

                        }

                }
                EditorGUI.BeginChangeCheck ();

                timeCurrent = GUILayout.HorizontalSlider (timeCurrent, 0, timeTotal);
                EditorGUILayout.BeginHorizontal ();
                int i;
                if (curves != null && variables != null) {
                        EditorGUILayout.BeginVertical ();
                        for (i = 0; i < curves.Length; i++)
                if(curves[i]!=null)
                                EditorGUILayout.CurveField (variables [i].memberPath, curves [i]);

                        EditorGUILayout.EndVertical ();
                }

                //Debug.Log (Time.renderedFrameCount+" "+Application.targetFrameRate);

                if (Time.realtimeSinceStartup - timeLast > 0.016) {
                        frameCount++;
                        timeLast = Time.realtimeSinceStartup;
                        if (curves != null && variables != null && curves.Length > 0) {
        //						for (i = 0; i < curves.Length; i++) {
        //								if (curves [i] != null) {

                                Quaternion quatNew = new Quaternion (curves [0].Evaluate (timeCurrent), curves [1].Evaluate (timeCurrent), curves [2].Evaluate (timeCurrent), curves [3].Evaluate (timeCurrent));

                                //animatedObject.transform.GetChild(0).GetChild(0).transform.localRotation=quatNew;

                                Debug.Log ("quatNew " + quatNew);

                                variables [0].Value = curves [0].Evaluate (timeCurrent);
                                variables [1].Value = curves [1].Evaluate (timeCurrent);
                                variables [2].Value = curves [2].Evaluate (timeCurrent);
                                variables [3].Value = curves [3].Evaluate (timeCurrent);

                                Debug.LogFormat ("{0} {1} {2} {3}", variables [0].Value, variables [1].Value, variables [2].Value, variables [3].Value);
                                Debug.Log ("status:" + animatedObject.transform.GetChild (0).GetChild (0).transform.localRotation);

                                Debug.Log ("======== end ----------");

                                //animatedObject.transform.GetChild(0).GetChild(0).transform.localRotation=

                                //variables [i].Value = curves [i].Evaluate (timeCurrent);
                                //if(i>0){
                                //variables[i].Value=curves [i].Evaluate (timeCurrent);

                                //Debug.Log (variables [i]+" FRM:"+frameCount);
                                //}
                                //}
                                //}

                        }
                }

                EditorGUILayout.LabelField ("", timeCurrent.ToString () + " s");
                EditorGUILayout.EndHorizontal ();

                if (clip != null && animatedObject != null) {

                        if (GUILayout.Button ("Reset Pose")) {

                                //Vector3 positionSaved=animatedObject1.transform.position;
                                UnityEditorInternal.ComponentUtility.CopyComponent (animatedObject1.transform);

                                PropertyModification[] modifications = PrefabUtility.GetPropertyModifications (animatedObject1).Select ((itm) => itm).Where ((itm) => itm.target.GetType () != typeof(UnityEngine.Transform)).ToArray ();

                                //PrefabUtility.ResetToPrefabState(animatedObject1);

                                PrefabUtility.SetPropertyModifications (animatedObject1, modifications);

                                //animatedObject1.transform.position=positionSaved;
                                UnityEditorInternal.ComponentUtility.PasteComponentValues (animatedObject1.transform);

                        }

                        EditorGUILayout.LabelField ("Frame:", ((int)(timeCurrent * clip.frameRate)).ToString ());

                        if (EditorGUI.EndChangeCheck () && AnimationMode.InAnimationMode ()) {

                                AnimationModeUtility.SampleClipBindingAt (new GameObject[] {
                                        animatedObject,
                                        animatedObject1
                                }, new AnimationClip[] {
                                        clip,
                                        clip1
                                }, ref timeCurrent);

                boneRoot.transform.position= animatedObjectPosition +boneRoot.transform.position;
                Debug.Log ("pos z:"+animatedObject1.transform.GetChild(2).GetChild(0).transform.position.z+" lpos z:"+animatedObject1.transform.GetChild(2).GetChild(0).transform.localPosition.z);
                //animatedObject1.transform.GetChild(2).GetChild(0).transform.position=animatedObject1.transform.GetChild(2).GetChild(0).transform.position-animatedObjectPosition;

                        }

            bSave = EditorGUILayout.Toggle ("Save:",bSave);

        //		Debug.Log (timeCurrent + " " + AnimationMode.InAnimationMode ());
                        if (GUILayout.Button ("StartAnimationMode") && !AnimationMode.InAnimationMode ()) {
                                AnimationMode.StartAnimationMode ();

                //if(animatedObjectPosition==null)

                        boneRoot=animatedObject1.GetRootBone();

                var bonePositionPrev=boneRoot.transform.position;
                //animatedObjectPosition=-boneRoot.transform.position;
                                AnimationModeUtility.SampleClipBindingAt (new GameObject[] {
                                        animatedObject,
                                        animatedObject1
                                }, new AnimationClip[] {
                                        clip,
                                        clip1
                                }, ref timeCurrent);

                animatedObjectPosition=bonePositionPrev-boneRoot.transform.position;

                Debug.Log("start: diff="+animatedObjectPosition+" GO:"+animatedObject1.transform.position+" "+boneRoot.transform.position);

                boneRoot.transform.position= animatedObjectPosition +boneRoot.transform.position;

                Debug.Log("at star bone should be same as animatedObject1 BONE:"+boneRoot.transform.position+" GO:"+animatedObject1.transform.position);

                        if (bSave)

                                        SetAutoRecordMode (true);

                        }

                        if (GUILayout.Button ("StopAnimationMode")) {
                                AnimationMode.StopAnimationMode ();

                                bSave=false;
                                SetAutoRecordMode (false);
                        }

                }
    }