Example #1
0
        public static CombatSettings CreateFromEnemyGroup(EnemyGroup enemyGroup, CombatDifficulty difficulty, PartyDataWrapper playerParty)
        {
            int enemyCount = 1;

            switch (difficulty)
            {
            case CombatDifficulty.Easy:
                enemyCount = Math.Max(1, RANDOM.Next(1, playerParty.Characters.Count));
                break;

            case CombatDifficulty.Normal:
                enemyCount = Math.Max(2, RANDOM.Next(playerParty.Characters.Count - 1, playerParty.Characters.Count + 1));
                break;

            case CombatDifficulty.Hard:
                enemyCount = Math.Max(2, RANDOM.Next(playerParty.Characters.Count - 1, playerParty.Characters.Count + 2));
                break;
            }

            List <EnemyDefinition> enemyTypes = new List <EnemyDefinition>(enemyCount);

            for (int i = 0; i < enemyCount; i++)
            {
                enemyTypes.Add(RandomResultGenerator.Get(enemyGroup.EnemyTypesByRarity));
            }

            return(CreateFromEnemyTypes(enemyTypes, difficulty, playerParty));
        }
Example #2
0
    bool SpaceAvailable(EnemyGroup group, Vector2Int placement, Facing facing)
    {
        if (!InBounds(placement))
        {
            return(false);
        }

        List <Vector2Int> to_check = new List <Vector2Int>();

        for (int x = 0; x < group.size.x; x++)
        {
            for (int y = 0; y < group.size.y; y++)
            {
                to_check.Add(GetRotatedPosition(group.anchor, new Vector2Int(x, y), facing) + placement);
            }
        }
        foreach (Vector2Int check in to_check)
        {
            if (point_to_piece.ContainsKey(check) && point_to_piece[check].blocks_path)
            {
                return(false);
            }
            if (point_to_enemy_group.ContainsKey(check))
            {
                return(false);
            }
        }
        return(true);
    }
Example #3
0
    /// <summary>
    /// Splits the groups *evenly* and returns how many you asked for.
    /// May not return fully evenly if the amount of ships cannot be spread evenly. The last group will always have the lowest amount of ships.
    ///
    /// TODO change it so it alternates back and forth so that the last group does not have the least amount of ships for each shipsize.
    /// </summary>
    /// <param name="groupCount">Amount of groups to be created</param>
    /// <returns>All groups asked for.</returns>
    public EnemyGroup[] SplitGroup(int groupCount)
    {
        EnemyGroup[] groups = new EnemyGroup[groupCount];

        for (int i = 0; i < groupCount; ++i)
        {
            groups[i] = new GameObject("EnemyGroup").AddComponent <EnemyGroup>();
        }

        // loop through each ships type list and add to groups
        for (int i = 0; i < m_children.Length; ++i)
        {
            int shipsCount = m_children[i].Count;

            //loop and add ships from this type to group
            for (int a = 0; a < groupCount; ++a)
            {
                //make sure we dont try to assign too many ships to the groups eg. if there are 8 ships being split between 3 groups, the last group should only receive 2 ships.
                int shipsPerGroup = Mathf.Min(Mathf.CeilToInt(shipsCount / (float)groupCount), shipsCount - a * Mathf.CeilToInt(shipsCount / (float)groupCount));
                for (int b = 0; b < shipsPerGroup; ++b)
                {
                    groups[a].AddEnemyToGroup(m_children[i][0]);
                    m_children[i].RemoveAt(0);
                }
            }
        }

        Destroy(this.gameObject);

        return(groups);
    }
Example #4
0
    //Create Waves of Enemy from List of Interger
    public void InitiateWave(Wave wave)
    {
        for (int i = 0; i < 6; i++)
        {
            if (wave._enemyFormation[i] > 0)
            {
                float position1, position2;
                if (!wave._isRandom)
                {
                    position1 = (-25 + i * 10) / 10.0f;
                }
                else
                {
                    position1 = (UnityEngine.Random.Range(0, 10) - 30 + i * 10) / 10.0f;
                }

                if (wave._canMove)
                {
                    position2 = position1 + UnityEngine.Random.Range(1, 3) * RandomOne();
                }
                else
                {
                    position2 = position1;
                }

                m_gameObject = (GameObject)Instantiate(m_enemy, new Vector3(position1, m_upperEdge.transform.position.y, 0f), Quaternion.identity);
                enemyGroup   = m_gameObject.GetComponent <EnemyGroup>();
                enemyGroup.SetState(position1, position2, wave._enemyFormation[i]);
            }
        }
    }
Example #5
0
        public GameScreen(Game game) : base(game)
        {
            _spriteBatch = new SpriteBatch(game.GraphicsDevice);

            AudioManager.StartTheme();

            _player          = new Player();
            _player.Position = new Vector2(AlienAttackGame.ScreenWidth / 2 - _player.Width / 2, AlienAttackGame.ScreenHeight - 120);
            _playerShots     = new List <PlayerShot>();

            _font = game.Content.Load <SpriteFont>("font");

            // draw a lives status icon in the lower left
            _livesIcon = new Player();

            // cache explosion
            new Explosion();

            _bgScreen           = game.Content.Load <Texture2D>("gfx\\bgScreen");
            _livesIcon.Position = new Vector2(20, AlienAttackGame.ScreenHeight - 80);
            _livesIcon.Scale    = new Vector2(0.5f, 0.5f);

            _enemyGroup = new EnemyGroup();

            _lives = 2;
        }
Example #6
0
    public List <EnemyGroup> enemyGroups;                              // Enemy groups reference.

    /// <summary>
    /// Add enemy group to the
    /// enemy group list.
    /// </summary>
    /// <param name="enemyGroup">EnemyGroup - enemy group instance reference.</parma>
    public void RegisterEnemyGroup(EnemyGroup enemyGroup)
    {
        if (!CheckIfRegistered(enemyGroup.id))
        {
            enemyGroups.Add(enemyGroup);
        }
    }
Example #7
0
    /// <summary>
    /// Creates an enemy for the spirit side of the battlefield.
    /// </summary>
    /// <param name="values"></param>
    /// <param name="group"></param>
    /// <param name="index"></param>
    private void CreateS(EnemyEntry values, EnemyGroup group)
    {
        if (!spawnTop)
        {
            return;
        }
        ggobjS = Instantiate(values.enemyModelS) as Transform;
        int side = Random.Range(0, 2);
        SStateController    state  = ggobjS.GetComponent <SStateController>();
        HurtableEnemyScript hurt   = ggobjS.GetComponent <HurtableEnemyScript>();
        AttackScript        attack = ggobjS.GetComponent <AttackScript>();

        if (side == 0)
        {
            state.leftSide = true;
        }

        ggobjS.position = state.GetRandomLocation();

        hurt.group = group;

        state.enemyid = enemyId;
        state.values  = ScriptableObject.CreateInstance <EnemyEntry>();
        state.values.CopyValues(values);

        group.top = hurt;
        group.sStateController = state;
        group.sTransform       = ggobjS;
        group.sAttackScript    = attack;
    }
Example #8
0
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////
    #region Helpers
    private Transform GetParentTransform(eEditablePrefabs forType)
    {
        if (forType == eEditablePrefabs.Brawler || forType == eEditablePrefabs.Scurrier)
        {
            EnemyGroup found = currentRoom.gameObject.GetComponentInChildren <EnemyGroup>();
            if (found == null)
            {
                Debug.Log("Could not find parent for new enemy");
                return(null);
            }
            return(found.transform);
        }
        else
        {
            OreVein foundOre = currentRoom.gameObject.GetComponentInChildren <OreVein>();
            if (foundOre)
            {
                return(foundOre.gameObject.transform.parent);
            }
            HealthFruit foundFruit = currentRoom.gameObject.GetComponent <HealthFruit>();
            if (foundFruit)
            {
                return(foundFruit.gameObject.transform.parent);
            }

            Debug.Log("Could not find the parent for new pickup");
            return(null);
        }
    }
Example #9
0
    IEnumerator GroupCoroutine(EnemyGroup group, List <int> randomFastIndicies, List <int> randomAttackingIndicies)
    {
        yield return(new WaitForSeconds(group.initialDelay));

        for (int i = 0; i < group.number; i++)
        {
            yield return(new WaitForSeconds(group.timeDelay));

            //spawn enemy
            GameObject enemyObj = Instantiate(enemyPrefabs[(int)group.enemy].gameObject, enemyParent);

            enemyObj.transform.position = startCubes [group.startCubeIndex].RandomPositionInBounds;

            Enemy e = enemyObj.GetComponent <Enemy> ();

            if (randomFastIndicies.Contains(i))
            {
                e.moveSpeed = this.fastEnemySpeed;
            }

            if (randomAttackingIndicies.Contains(i))
            {
                e.attackRange = this.attackingEnemyRange;
            }

            //start pathfinding
            e.Begin(startCubes [group.startCubeIndex]);

            EnemyPathManager.Instance.AddEnemyToPathManager(e);

            enemiesLeftToSpawn--;
        }
    }
Example #10
0
 public static void GetGoldValue(BaseData base_data, out int min, out int max)
 {
     min = max = 0;
     foreach (BaseData.BasePieceData piece_data in base_data.base_pieces_by_id)
     {
         if (piece_data == null)
         {
             continue;
         }
         BasePiece bp = base_pieces.GetBasePieceFromID(piece_data.id);
         if (bp != null)
         {
             min += bp.gold_value;
         }
     }
     foreach (BaseData.EnemyGroupData enemy_group_data in base_data.enemy_group_by_id)
     {
         if (enemy_group_data == null)
         {
             continue;
         }
         EnemyGroup eg = enemy_groups.GetEnemyGroupFromID(enemy_group_data.id);
         if (eg != null)
         {
             max += eg.GetGoldValue();
         }
     }
     max += min;
 }
Example #11
0
 public void CreateEnemyGroup()
 {
     m_timeCounter++;
     if (m_timeCounter >= m_timeLimit)
     {
         m_timeCounter           = 0;
         UnityEngine.Random.seed = System.Guid.NewGuid().GetHashCode();
         for (int i = 0; i < enemyNumber; i++)
         {
             int percent = UnityEngine.Random.Range(0, 100);
             if (percent > percentNotMove)
             {
                 float position1 = UnityEngine.Random.Range(-30, 30) / 10f;
                 float position2 = UnityEngine.Random.Range(-30, 30) / 10f;
                 int   time      = UnityEngine.Random.Range(touchLowerTimes, touchUpperTimes);
                 m_gameObject = (GameObject)Instantiate(m_enemy, new Vector3(position1, m_upperEdge.transform.position.y, 0f), Quaternion.identity);
                 enemyGroup   = m_gameObject.GetComponent <EnemyGroup>();
                 enemyGroup.SetState(position1, position2, time);
             }
             else
             {
                 float position1 = UnityEngine.Random.Range(-30, 30) / 10f;
                 float position2 = position1;
                 int   time      = UnityEngine.Random.Range(touchLowerTimes, touchUpperTimes);
                 m_gameObject = (GameObject)Instantiate(m_enemy, new Vector3(position1, m_upperEdge.transform.position.y, 0f), Quaternion.identity);
                 enemyGroup   = m_gameObject.GetComponent <EnemyGroup>();
                 enemyGroup.SetState(position1, position2, time);
             }
         }
     }
 }
Example #12
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        EnemyGroup group = target as EnemyGroup;

        if (GUILayout.Button("Simulate Enemy Damaged"))
        {
            group.OnEnemyDamage.Invoke();
        }
        if (GUILayout.Button("Simulate Attack/Ability Used"))
        {
            group.OnShotFired.Invoke();
        }
        if (GUILayout.Button("Simulate Grabbed Hyperseed"))
        {
            group.GrabHyperseed.Invoke();
        }
        if (GUILayout.Button("Turn Group Aggressive"))
        {
            group.TurnGroupAggressive.Invoke();
        }
        if (GUILayout.Button("Turn Group Passive"))
        {
            group.TurnGroupPassive.Invoke();
        }
    }
Example #13
0
 public void RemoveActiveGroup(EnemyGroup group)
 {
     if (activeGroups.Contains(group))
     {
         activeGroups.Remove(group);
     }
 }
Example #14
0
 public void BattleHappen(EnemyGroup eg, OptionSource op = null)
 {
     BattleManager.information = new PassedBattleInformation {
         enemyGroup = eg, difficultLevel = this.difficultLevel, option = op
     };
     SceneStatusManager.Ins.SetSceneStatus(new BattleStatus(SceneStatusManager.Ins), true, true);
 }
Example #15
0
    // Update is called once per frame
    void Update()
    {
        foreach (var i in levelData)
        {
            float realDistance = background.distance * 100;
            if (realDistance < i.distance)
            {
                if (currentLevel == i.id)
                {
                    break;
                }

                ChangeLevel(i.id);
                break;
            }
        }

        if (timer > delay)
        {
            EnemyGroup go = Instantiate <EnemyGroup>(enemyOrigin);
            go.gameObject.SetActive(true);
            go.transform.position = transform.position;
            timer            = 0;
            go.enemyTemplete = currentEnemy.gameObject;
        }

        timer += Time.deltaTime;
    }
Example #16
0
    public void SpawnEnemies(Room spawnRoom, int enemyCount)
    {
        EnemyGroup group = new EnemyGroup();

        deathCount = 0;

        if (!spawnRoom.isActive)
        {
            spawnRoom.Show();
        }

        for (int i = 0; i < enemyCount; i++)
        {
            Vector3        spawnPos = SpawnPosFromRoom(spawnRoom);
            EnemyCharacter enemy    = GameObjectFactory.Instantiate <EnemyCharacter>(enemyPrefab, position: spawnPos);
            enemy.transform.parent = transform;
            enemy.Spawn(spawnRoom);
            enemy.DeathEvent += EnemyDied;

            enemy.SetRank(Random.Range(1, roundCount + 3));

            _enemies.Add(enemy);
            group.Add(enemy);
        }
    }
Example #17
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.GetComponent <RoomCollision>() != null)
        {
            _currentRoom = other.GetComponent <RoomCollision>().room;

            if (_currentRoom != null)
            {
                if (_currentRoom.GetComponentInChildren <EnemyGroup>() != null)
                {
                    if (_enemyGroup)
                    {
                        _enemyGroup.OnPlayerExit.Invoke();
                    }
                    _enemyGroup = _currentRoom.GetComponentInChildren <EnemyGroup>();
                    _enemyGroup.OnPlayerEnter.Invoke();
                    GetComponent <PlayerBase>().currentRoom = _currentRoom;
                }
                else
                {
                    _enemyGroup = null;
                }
            }
            else
            {
                _enemyGroup = null;
            }
        }
    }
 private void Awake()
 {
     Id    = TargetId;
     group = transform.parent.GetComponent <EnemyGroup>();
     group.Add(Id, transform.parent.position.XY() + Random.insideUnitCircle.normalized * wanderRadius);
     GetComponent <HealthComponent>().DeathDelegate += KillEnemy;
     animator = GetComponent <Animator>();
 }
Example #19
0
    //敵オブジェクト取得処理
    //***敵コンポーネント取得して、レベル設定してから渡す
    public GameObject GetEnemyObject()
    {
        //リストからランダムに敵データを取得
        EnemyGroup _enemy = m_enemyGroups.GetAtRandom();

        //***レベル設定してから渡す

        return(_enemy.obj);
    }
Example #20
0
    /// <summary>
    /// Creates an enemy group with the given enemy index.
    /// </summary>
    /// <param name="index"></param>
    /// <returns></returns>
    private EnemyGroup CreateGroup(EnemyEntry ee)
    {
        EnemyGroup group = new EnemyGroup(enemyId, ee.maxhp);

        enemyId++;
        group.deadEnemy = deadEnemy;
        CreateN(ee, group);
        CreateS(ee, group);
        return(group);
    }
Example #21
0
    public bool TryPlaceEnemy(EnemyGroup selected_group, Vector2Int position, Facing facing)
    {
        if (selected_group == null || !SpaceAvailable(selected_group, position, facing) || !inventory_tracker.CanPlaceGroup(selected_group.id))
        {
            return(false);
        }

        PlaceEnemy(selected_group, position, facing);
        return(true);
    }
Example #22
0
 /// <summary>
 /// Add a group of enemies to this wave
 /// </summary>
 /// <param name="group"></param>
 public void AddEnemyGroup(EnemyGroup group)
 {
     EnemyGroup[] temp = new EnemyGroup[enemies.Length + 1];
     for (int i = 0; i < enemies.Length; i++)
     {
         temp[i] = enemies[i];
     }
     temp[temp.Length - 1] = group;
     enemies = temp;
 }
Example #23
0
        public SortedSet <int> GetGroup(string name)
        {
            EnemyGroup group = Groups.Find(g => g.Name == name);

            if (group == null)
            {
                return(new SortedSet <int>());
            }
            return(group.Entities);
        }
Example #24
0
    private void SpawnEnemies(EnemyGroup group)
    {
        if (inActiveGroups.Contains(group))
        {
            inActiveGroups.Remove(group);
        }

        lastMoved = 0;
        activeGroups.Add(group);
        group.ActivateGroup();
    }
Example #25
0
 public void SetSelectedGroup(EnemyGroup group)
 {
     if (selected_group != null)
     {
         Destroy(selected_group.gameObject);
     }
     if (group != null)
     {
         selected_group = Instantiate(group);
     }
 }
Example #26
0
    EnemyGroup SpawnEnemyGroup(EnemyGroup enemy, Vector2Int position, Facing facing)
    {
        EnemyGroup new_enemy_group = Instantiate(enemy);

        new_enemy_group.position           = position;
        new_enemy_group.facing             = facing;
        new_enemy_group.transform.position = (Vector3)(position.ToVector3Int(Vector3Axis.y) - new_enemy_group.anchor.ToVector3Int(Vector3Axis.y)) * scale * block_size;
        new_enemy_group.transform.rotation = Quaternion.Euler(Vector2.up * (int)facing);

        return(new_enemy_group);
    }
 void InventoryRefresh()
 {
     foreach (int group_id in tracker.tracked_inventory.AllAvailableEnemyGroups())
     {
         PieceSelectionButton new_button             = Instantiate(selection_prefab, button_holder);
         EnemyGroup           enemy_group_to_emulate = Database.enemy_groups.GetEnemyGroupFromID(group_id);
         new_button.title     = enemy_group_to_emulate.name;
         new_button.count_max = tracker.tracked_inventory.GetEnemyGroupCount(group_id);
         new_button.count     = new_button.count_max - tracker.GroupsPlaced(group_id);
         new_button.button.onClick.AddListener(() => build_manager.place_enemies.SetSelectedGroup(enemy_group_to_emulate));
     }
 }
    void CheckSpawning()
    {
        EnemyGroup group = null;

        float delta = Time.deltaTime;

        for (int i = enemiesWaitingToSpawn.Count - 1; i >= 0; --i)
        {
            SpawnLocation spawn = enemiesWaitingToSpawn[i];
            spawn.currentTime += delta;

            if (spawn.currentTime >= spawn.timeUntilStart)
            {
                networkView.RPC("PropagateNewSpawnEffect", RPCMode.All, activeTime, enemiesWaitingToSpawn[i].location, enemiesWaitingToSpawn[i].scale);

                // move the SpawnLocation from waitingToSpawn to beingSpawned
                enemiesBeingSpawned.Add(spawn);
                enemiesWaitingToSpawn.RemoveAt(i);

                // reset the values so that they are correct
                spawn.currentTime    = 0;
                spawn.timeUntilStart = activeTime;
            }
        }



        for (int i = enemiesBeingSpawned.Count - 1; i >= 0; --i)
        {
            SpawnLocation spawn = enemiesBeingSpawned[i];
            spawn.currentTime += delta;

            if (spawn.currentTime >= spawn.timeUntilStart)
            {
                GameObject enemy = (GameObject)Network.Instantiate(spawn.prefab, spawn.location, this.transform.rotation, 0);

                EnemyScript script = enemy.GetComponent <EnemyScript>();
                spawn.parentGroup.AddEnemyToGroup(script);
                group = spawn.parentGroup;

                HealthScript health = enemy.GetComponent <HealthScript>();
                health.SetModifier(modifier);

                enemiesBeingSpawned.RemoveAt(i);
            }
        }

        if (enemiesWaitingToSpawn.Count == 0 && enemiesBeingSpawned.Count == 0)
        {
            group.CancelAllOrders();
            Activate(false);
        }
    }
Example #29
0
    public void IdleEnemiesCommand()
    {
        EnemyGroup roomEnemies = GetRoomEnemies();

        if (roomEnemies == null)
        {
            Debug.Log("Idle enemies command failed. Could not find EnemyGroup");
            return;
        }

        Debug.Log("Commanded enemies to be idle");
        roomEnemies.TurnGroupPassive.Invoke();
    }
Example #30
0
    ////////////////////////////////////////////////////////////////////////////////////////////////
    #region Respond to input events
    /// <summary>
    /// Public functions to react to input and run a command.
    /// Hook these up to the Unity Events provided on the Console_Button game object
    /// William Austin
    /// </summary>
    ///
    ////////////////////////////////////////////////////////////////////////////////////////////////
    #region Enemy Commands

    public void AgroEnemiesCommand()
    {
        EnemyGroup roomEnemies = GetRoomEnemies();

        if (roomEnemies == null)
        {
            Debug.Log("Argo enemies command failed. Could not find EnemyGroup");
            return;
        }

        Debug.Log("Commanded enemies to be aggro");
        roomEnemies.TurnGroupAggressive.Invoke();
    }
    public void Start()
    {
        foreach (Transform child in transform) {
            Enemy childScript = child.GetComponent<Enemy> ();
            if(childScript != null)
                ++enemies;
        }

        Transform parentTr = transform.parent;
        if (parentTr != null) {
            parentGroup = transform.parent.GetComponent<EnemyGroup> ();
            if(parentGroup != null) parentGroup.addEnemies(enemies);
        }

        PostStart ();
    }
Example #32
0
 public CombatScreen()
 {
     Entries = Session.currentSession.Party;
     this.Group = CombatEngine.CreateRandomForMap(Session.currentSession.Map);
     Enemies = new List<Character>();
     CombatExp = 0;
     Items = new List<ItemDrop>();
     foreach (EnemyGroupEntry gEntry in Group.Group)
     {
         Character Char = new Character(gEntry.Name, (Weapon)ItemPool.Instance.GetItem(gEntry.WeaponName), (Armour)ItemPool.Instance.GetItem(gEntry.ArmourName));
         Char.AI = gEntry.AI;
         Char.SetLevel(gEntry.Level);
         Char.DisplayName = gEntry.DisplayName;
         Enemies.Add(Char);
         CombatExp += gEntry.Experience;
         Items.AddRange(gEntry.Items);
     }
 }
Example #33
0
        private bool LoadFile( Stream stream )
        {
            string magic = stream.ReadAscii( 8 );
            uint enemyGroupCount = stream.ReadUInt32().SwapEndian();
            uint refStringStart = stream.ReadUInt32().SwapEndian();

            EnemyGroupList = new List<EnemyGroup>( (int)enemyGroupCount );
            for ( uint i = 0; i < enemyGroupCount; ++i ) {
                EnemyGroup s = new EnemyGroup( stream, refStringStart );
                EnemyGroupList.Add( s );
            }

            EnemyGroupIdDict = new Dictionary<uint, EnemyGroup>( EnemyGroupList.Count );
            foreach ( EnemyGroup e in EnemyGroupList ) {
                EnemyGroupIdDict.Add( e.InGameID, e );
            }

            return true;
        }
    public virtual void Start()
    {
        PreStart ();
        explosionPool = GameObject.Find("ObjectPool EnemyExplosions").GetComponent<ObjectPoolerScript>();
        upgradePool = GameObject.Find("ObjectPool ItemUpgrades").GetComponent<ObjectPoolerScript>();

        weapons = new EnemyWeapon[weaponNames.Count];
        for (int i = 0; i < weaponNames.Count; ++i) {
            GameObject   weapon = GameObject.Find ("EnemyWeapon Container/EnemyWeapon " + weaponNames [i]);
            EnemyWeapon script = null;

            if(weapon == null)
                Debug.LogError("Can't find EnemyWeapon Container/EnemyWeapon " + weaponNames [i]);
            else
                script = weapon.GetComponent<EnemyWeapon>();
            if(script == null)
                Debug.LogError("Can't get weapon for index " + i);

            weapons[i] = script;
        }

        mySpriteRdr = GetComponent<SpriteRenderer>();
        myAnim = GetComponent<Animator> ();
        myTr = transform;

        if (myTr.parent != null && myTr.parent.GetComponent<EnemyGroup> () != null)
            group = myTr.parent.GetComponent<EnemyGroup> ();

        myRb = GetComponent<Rigidbody2D>();
        if(myRb != null)
            myRb.gravityScale *= myTr.up.y;

        GameObject player = GameObject.FindWithTag ("Player");
        playerScript =  player.GetComponent<PlayerScript>();
        playerTr = player.transform;

        gamePause = false;
        asleep = true;
        hp = maxHp;

        StartCoroutine(DisableCollider());
        PostStart ();
    }