Exemple #1
0
        public void Despawn(string poolName, Logic.Character.CharacterEntity character)
        {
            SpawnPool spawnPool = Pool.Controller.PoolController.instance.GetPool(poolName);

            if (spawnPool)
            {
                if (character is Logic.Character.PlayerEntity)
                {
                    Logic.Character.PlayerEntity playerEntity = character as Logic.Character.PlayerEntity;
                    if (playerEntity.petEntity != null)
                    {
                        LockTransform lockTransform = playerEntity.petEntity.gameObject.GetComponent <LockTransform>();
                        if (lockTransform)
                        {
                            lockTransform.trans = null;
                        }
                        Despawn(playerEntity.petEntity.name, playerEntity.petEntity.transform);
                    }
                    playerEntity.petEntity = null;
                }
                else if (character is Logic.Character.EnemyPlayerEntity)
                {
                    Logic.Character.EnemyPlayerEntity enemyPlayerEntity = character as Logic.Character.EnemyPlayerEntity;
                    if (enemyPlayerEntity.petEntity != null)
                    {
                        LockTransform lockTransform = enemyPlayerEntity.petEntity.gameObject.GetComponent <LockTransform>();
                        if (lockTransform)
                        {
                            lockTransform.trans = null;
                        }
                        Despawn(enemyPlayerEntity.petEntity.name, enemyPlayerEntity.petEntity.transform);
                    }
                    enemyPlayerEntity.petEntity = null;
                }
                character.transform.SetParent(spawnPool.transform, false);
                spawnPool.Despawn(character.transform);
            }
        }
    public override void OnInspectorGUI()
    {
        Source = (LockTransform)target;

        base.OnInspectorGUI();
        int lockLabelWidth   = 110;
        int spaceOptionWidth = 100;
        int localPosition    = Source.LockLocalPosition ? 1 : 0;
        int localRotation    = Source.LockLocalRotation ? 1 : 0;

        string[] space = new string[] { "World", "Local" };

        GUILayout.BeginHorizontal();
        GUILayout.Label("Lock Position", GUILayout.Width(lockLabelWidth));
        Source.LockLocalPosition = EditorGUILayout.Popup("", localPosition, space, GUILayout.Width(spaceOptionWidth)) == 1;
        Source.LockPosition[0]   = GUILayout.Toggle(Source.LockPosition[0], "X");
        Source.LockPosition[1]   = GUILayout.Toggle(Source.LockPosition[1], "Y");
        Source.LockPosition[2]   = GUILayout.Toggle(Source.LockPosition[2], "Z");
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        GUILayout.Label("Lock Rotation", GUILayout.Width(lockLabelWidth));
        Source.LockLocalRotation = EditorGUILayout.Popup("", localRotation, space, GUILayout.Width(spaceOptionWidth)) == 1;
        Source.LockRotation[0]   = GUILayout.Toggle(Source.LockRotation[0], "X");
        Source.LockRotation[1]   = GUILayout.Toggle(Source.LockRotation[1], "Y");
        Source.LockRotation[2]   = GUILayout.Toggle(Source.LockRotation[2], "Z");
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        GUILayout.Label("Lock Scale", GUILayout.Width(lockLabelWidth));
        GUILayout.Label(space[1], GUILayout.Width(spaceOptionWidth));
        Source.LockScale[0] = GUILayout.Toggle(Source.LockScale[0], "X");
        Source.LockScale[1] = GUILayout.Toggle(Source.LockScale[1], "Y");
        Source.LockScale[2] = GUILayout.Toggle(Source.LockScale[2], "Z");
        GUILayout.EndHorizontal();
    }