Esempio n. 1
0
    void Start()
    {
        _objectPoolingManager = ObjectPoolingManager.Instance;

        if (TotalVisiblePlatforms >= PlatformPositions.Count)
        {
            throw new ArgumentOutOfRangeException("Total visible platforms must be less or equal the number of platform positions.");
        }

        if (TotalInitialVisiblePlatforms >= PlatformPositions.Count)
        {
            throw new ArgumentOutOfRangeException("Total initial visible platforms must be less or equal the number of platform positions.");
        }

        for (var i = 0; i < PlatformPositions.Count; i++)
        {
            _worldSpacePlatformCoordinates.Add(transform.TransformPoint(PlatformPositions[i]));
        }

        for (var i = 0; i < TotalInitialVisiblePlatforms; i++)
        {
            var platform = _objectPoolingManager.GetObject(
                PlatformPrefab.name,
                _worldSpacePlatformCoordinates[i]);

            _currentPlatforms.Enqueue(platform);

            _currentIndex = i;
        }
    }
Esempio n. 2
0
    void OnEnable()
    {
        _objectPoolingManager = ObjectPoolingManager.Instance;

        Logger.Info("Enabling half wheel " + this.name);

        GameObject platform = _objectPoolingManager.GetObject(floatingAttachedPlatform.name);

        _currentAngle = startDirection == Direction.Right ? -Mathf.PI : 0f;

#if USE_CIRCLE
        Quaternion q = Quaternion.AngleAxis(_currentAngle, Vector3.forward);

        Vector3 rotated = new Vector3(width * Mathf.Cos(_currentAngle), height * Mathf.Sin(_currentAngle), 0.0f);
        rotated = q * rotated + this.transform.position;
#else
        Vector3 initial = new Vector3(transform.position.x + radius, transform.position.y, transform.position.z);
        Vector3 rotated = new Vector3(
            Mathf.Cos(_currentAngle) * (initial.x - transform.position.x) - Mathf.Sin(_currentAngle) * (initial.y - transform.position.y) + transform.position.x
            , Mathf.Sin(_currentAngle) * (initial.x - transform.position.x) + Mathf.Cos(_currentAngle) * (initial.y - transform.position.y) + transform.position.y
            , transform.position.z);
#endif

        platform.transform.position = rotated;

        _platform         = platform;
        _currentDirection = startDirection;
        _nextStartTime    = Time.time + stopDuration;
    }
Esempio n. 3
0
    void OnEnable()
    {
        _objectPoolingManager = ObjectPoolingManager.Instance;
        Logger.Trace("Enabling EnemySpawnManager " + this.name);

        _nextSpawnTime = Time.time;
    }
Esempio n. 4
0
    void OnEnable()
    {
        _objectPoolingManager = ObjectPoolingManager.Instance;

        Logger.Info("Enabling half wheel " + name);

        var platform = _objectPoolingManager.GetObject(FloatingAttachedPlatform.name);

        _currentAngle = StartDirection == Direction.Right
      ? -Mathf.PI
      : 0f;

        Vector3 initial = new Vector3(
            transform.position.x + Radius,
            transform.position.y,
            transform.position.z);

        Vector3 rotated = new Vector3(
            Mathf.Cos(_currentAngle) * (initial.x - transform.position.x) - Mathf.Sin(_currentAngle) * (initial.y - transform.position.y) + transform.position.x,
            Mathf.Sin(_currentAngle) * (initial.x - transform.position.x) + Mathf.Cos(_currentAngle) * (initial.y - transform.position.y) + transform.position.y,
            transform.position.z);

        platform.transform.position = rotated;

        _platform = platform;

        _currentDirection = StartDirection;

        _nextStartTime = Time.time + StopDuration;
    }
Esempio n. 5
0
    public void Start()
    {
        inventory       = new InventorySystem();
        equipmentSystem = new EquipmentManager();
        equipmentSystem.Start();
        objPoolManager = GameManager.instance.objPoolManager;

        //Test Items
        for (int i = 0; i < testItems.Length; i++)
        {
            inventory.Add(testItems[i].GetComponent <ItemPickup>().item, 17);
        }

        inventory.TestInventory();

        Invoke("setBounds", 0.1f);

        currentPath = null;

        localScale = healthbar.localScale;

        if (objPoolManager.itemmanager.tester == null)
        {
            objPoolManager.itemmanager.initializeEnemies();
        }
        else
        {
            objPoolManager.itemmanager.loadEnemies();
        }
    }
Esempio n. 6
0
    void OnEnable()
    {
        _objectPoolingManager = ObjectPoolingManager.Instance;
        _playerController     = GameManager.instance.player;

        Logger.Info("Enabled sentry canon " + this.GetHashCode());
    }
    void OnEnable()
    {
        _playerController = GameManager.instance.player;
        if (_objectPoolingManager == null)
        {
            _objectPoolingManager = ObjectPoolingManager.Instance;
            for (int i = 0; i < platformGroupPositions.Count; i++)
            {
                platformGroupPositions[i].gameObjects           = new GameObject[platformGroupPositions[i].positions.Count];
                platformGroupPositions[i].worldSpaceCoordinates = new Vector3[platformGroupPositions[i].positions.Count];
                for (int j = 0; j < platformGroupPositions[i].positions.Count; j++)
                {
                    platformGroupPositions[i].worldSpaceCoordinates[j] = this.transform.TransformPoint(platformGroupPositions[i].positions[j]);
                }
            }
        }

        if (platformGroupPositions.Count < 2)
        {
            throw new ArgumentOutOfRangeException("There must be at least two platform position groups.");
        }

        if (platformGroupStartIndex < 0 || platformGroupStartIndex >= platformGroupPositions.Count)
        {
            SwitchGroups(0);
        }
        else
        {
            SwitchGroups(platformGroupStartIndex);
        }

        _playerController.OnJumpedThisFrame += _playerController_OnJumpedThisFrame;
    }
Esempio n. 8
0
    void OnEnable()
    {
        _objectPoolingManager = ObjectPoolingManager.Instance;

        _startAngleRad = StartAngle * Mathf.Deg2Rad;

        _endAngleRad = EndAngle * Mathf.Deg2Rad;

        _totalAngleRad = Mathf.Abs(_endAngleRad - _startAngleRad);

        _isMovingTowardsEndPoint = true;

        _directionFactor = _startAngleRad > _endAngleRad
      ? -1f
      : 1f;

        var platform = _objectPoolingManager.GetObject(FloatingAttachedPlatform.name);

        _currentAngle = _startAngleRad;

        var initial = new Vector3(transform.position.x + Radius, transform.position.y, transform.position.z);

        var rotated = new Vector3(
            Mathf.Cos(_currentAngle) * (initial.x - transform.position.x) - Mathf.Sin(_currentAngle) * (initial.y - transform.position.y) + transform.position.x,
            Mathf.Sin(_currentAngle) * (initial.x - transform.position.x) + Mathf.Cos(_currentAngle) * (initial.y - transform.position.y) + transform.position.y,
            transform.position.z);

        platform.transform.position = rotated;

        _platform = platform;

        _nextStartTime = Time.time + StopDuration;
    }
Esempio n. 9
0
    void OnEnable()
    {
        _objectPoolingManager = ObjectPoolingManager.Instance;
        _playerController     = GameManager.instance.player;

        _currentfireDirectionVectorGroupIndex = 0;
    }
    private void Awake()
    {
        instance = this;
        enemies  = new List <GameObject>(3);

        //enemyPrefab = (GameObject)Resources.Load("Prefabs/Enemy", typeof(GameObject));
    }
Esempio n. 11
0
    void OnEnable()
    {
        _objectPoolingManager = ObjectPoolingManager.Instance;

        var platforms = new List <GameObjectContainer>();

        var twoPi = Mathf.PI * 2f;

        for (var angle = 0f; angle < twoPi; angle += twoPi / TotalPlatforms)
        {
            var platform = _objectPoolingManager.GetObject(FloatingAttachedPlatform.name);

            var quaternion = Quaternion.AngleAxis(angle, Vector3.forward);

            var rotated = new Vector3(
                Width * Mathf.Cos(angle),
                Height * Mathf.Sin(angle),
                0.0f);

            rotated = quaternion * rotated + transform.position;

            platform.transform.position = rotated;

            platforms.Add(new GameObjectContainer {
                GameObject = platform, Angle = angle
            });
        }

        _platforms = platforms;
    }
Esempio n. 12
0
    void OnEnable()
    {
        _objectPoolingManager = ObjectPoolingManager.Instance;

        Logger.Info("Enabling wheel " + this.name);
        List <GameObjectContainer> platforms = new List <GameObjectContainer>();

        for (float angle = 0f; angle < 360 * Mathf.Deg2Rad; angle += 360 * Mathf.Deg2Rad / totalPlatforms)
        {
            GameObject platform = _objectPoolingManager.GetObject(floatingAttachedPlatform.name);

            Vector3 initial = new Vector3(transform.position.x + radius, transform.position.y, transform.position.z);

            Vector3 rotated = new Vector3(
                Mathf.Cos(angle) * (initial.x - transform.position.x) - Mathf.Sin(angle) * (initial.y - transform.position.y) + transform.position.x
                , Mathf.Sin(angle) * (initial.x - transform.position.x) - Mathf.Cos(angle) * (initial.y - transform.position.y) + transform.position.y
                , transform.position.z);

            platform.transform.position = rotated;
            platforms.Add(new GameObjectContainer()
            {
                GameObject = platform, Angle = angle
            });
        }

        _platforms = platforms;
    }
Esempio n. 13
0
    void OnEnable()
    {
        _objectPoolingManager = ObjectPoolingManager.Instance;

        List <GameObjectContainer> platforms = new List <GameObjectContainer>();
        float twoPi = Mathf.PI * 2f;

        for (float angle = 0f; angle < twoPi; angle += twoPi / totalPlatforms)
        {
            GameObject platform = _objectPoolingManager.GetObject(floatingAttachedPlatform.name);

            Quaternion q = Quaternion.AngleAxis(angle, Vector3.forward);

            Vector3 rotated = new Vector3(width * Mathf.Cos(angle), height * Mathf.Sin(angle), 0.0f);
            rotated = q * rotated + this.transform.position;

            platform.transform.position = rotated;
            platforms.Add(new GameObjectContainer()
            {
                GameObject = platform, Angle = angle
            });
        }

        _platforms = platforms;
    }
Esempio n. 14
0
    // setup method is run before start
    void Awake()
    {
        instance = this;

        //Preload bullets
        bullets = new List <GameObject>(bulletAmount);
        //Preload grenades
        grenades = new List <GameObject>(grenadeAmount);

        for (int i = 0; i < bulletAmount; i++)
        {
            GameObject prefabInstance = Instantiate(bulletPrefab);
            prefabInstance.transform.SetParent(transform);
            prefabInstance.SetActive(false);
            bullets.Add(prefabInstance);
        }

        for (int i = 0; i < grenadeAmount; i++)
        {
            GameObject prefabInstance = Instantiate(grenadePrefab);
            prefabInstance.transform.SetParent(transform);
            prefabInstance.SetActive(false);
            grenades.Add(prefabInstance);
        }
    }
    void OnEnable()
    {
        if (PlatformGroups.Count < 1)
        {
            throw new ArgumentOutOfRangeException("There must be at least two platform position groups.");
        }

        _playerController = GameManager.Instance.Player;

        _objectPoolingManager = ObjectPoolingManager.Instance;

        for (var i = 0; i < PlatformGroups.Count; i++)
        {
            PlatformGroups[i].GameObjects = new List <GameObjectContainer>();
        }

        var index = 0;

        var twoPi = Mathf.PI * 2f;

        for (var angle = 0f; angle < twoPi; angle += twoPi / TotalPlatforms)
        {
            var quaternion = Quaternion.AngleAxis(angle, Vector3.forward);

            var rotated = new Vector3(Width * Mathf.Cos(angle), Height * Mathf.Sin(angle), 0.0f);

            rotated = quaternion * rotated + transform.position;

            GameObject platform = null; // note: we do allow null game objects in case it is a wheel with a single platform switch group

            if (PlatformGroups[index].DisabledGameObject != null)
            {
                platform = _objectPoolingManager.GetObject(PlatformGroups[index].DisabledGameObject.name);

                platform.transform.position = rotated;
            }

            PlatformGroups[index].GameObjects.Add(
                new GameObjectContainer()
            {
                GameObject = platform, Angle = angle
            });

            index = index < PlatformGroups.Count - 1
        ? index + 1
        : 0;
        }

        if (PlatformGroupStartIndex < 0 || PlatformGroupStartIndex >= PlatformGroups.Count)
        {
            SwitchGroups(0);
        }
        else
        {
            SwitchGroups(PlatformGroupStartIndex);
        }

        _playerController.JumpedThisFrame += OnPlayerJumpedThisFrame;
    }
Esempio n. 16
0
 void Awake()
 {
     if (Instance != null)
     {
         return;
     }
     Instance = this;
 }
Esempio n. 17
0
 public void Start()
 {
     if (holdsTraps)
     {
         trap = traps[Random.Range(0, traps.Length)];
     }
     obj = GameManager.instance.objPoolManager;
 }
Esempio n. 18
0
    void OnEnable()
    {
        Logger.Trace("Enabling EnemySpawnManager {0}", name);

        _objectPoolingManager = ObjectPoolingManager.Instance;

        _nextSpawnTime = Time.time;
    }
Esempio n. 19
0
    private void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
        }

        shinyLines = new List <GameObject>();
    }
Esempio n. 20
0
    private void OnDestroy()
    {
        if (Instance != this)
        {
            return;
        }

        Instance = null;
    }
Esempio n. 21
0
 // Start is called before the first frame update
 void Start()
 {
     instance = this;
     for (int i = 0; i < 500; i++)
     {
         GameObject t_object = Instantiate(m_goPrefab, Vector3.zero, Quaternion.identity);
         m_queue.Enqueue(t_object);
         t_object.SetActive(false);
     }
 }
Esempio n. 22
0
 public virtual void Start()
 {
     instance = this;
     MakeObjects(bulletPrefab, bulletQueue, 20);      //bullets
     MakeObjects(tBulletPrefab, tBulletQueue, 10);    //tbullets
     MakeObjects(tBullet2Prefab, tBullet2Queue, 10);  //tbullets2
     MakeObjects(expBallPrefab, expBallQueue, 20);    //expBalls
     MakeObjects(expPiecePrefab, expPieceQueue, 100); //expPieces
     MakeObjects(rfbPrefab, rfbQueue, 200);           //rotateFireball
 }
Esempio n. 23
0
    void Awake()
    {
        instance    = this;
        spawnRadius = 8;

        //For each color, generate a list with the starting amount
        //Then, fill the lists with circles of the aprropriate color
        //Circles are deactivated until the GetCircle Function is called
        Green = new List <GameObject> (eachAmount);

        for (int i = 0; i < eachAmount; i++)
        {
            GameObject prefabInstance = Instantiate(prefabCircleGreen);
            prefabInstance.transform.SetParent(transform);
            prefabInstance.SetActive(false);

            Green.Add(prefabInstance);
        }

        Blue = new List <GameObject> (eachAmount);

        for (int i = 0; i < eachAmount; i++)
        {
            GameObject prefabInstance = Instantiate(prefabCircleBlue);
            prefabInstance.transform.SetParent(transform);
            prefabInstance.SetActive(false);

            Blue.Add(prefabInstance);
        }

        Red = new List <GameObject> (eachAmount);

        for (int i = 0; i < eachAmount; i++)
        {
            GameObject prefabInstance = Instantiate(prefabCircleRed);
            prefabInstance.transform.SetParent(transform);
            prefabInstance.SetActive(false);

            Red.Add(prefabInstance);
        }

        Yellow = new List <GameObject> (eachAmount);

        for (int i = 0; i < eachAmount; i++)
        {
            GameObject prefabInstance = Instantiate(prefabCircleYellow);
            prefabInstance.transform.SetParent(transform);
            prefabInstance.SetActive(false);

            Yellow.Add(prefabInstance);
        }
    }
    // Start is called before the first frame update
    void Awake()
    {
        instance   = this;
        bulletList = new List <GameObject>(bulletCapacity);
        for (int i = 0; i < bulletCapacity; i++)
        {
            GameObject bulletObject = Instantiate(bulletPrefab);
            bulletObject.transform.SetParent(transform);
            bulletObject.SetActive(false);

            bulletList.Add(bulletObject);
        }
    }
Esempio n. 25
0
    // Start is called before the first frame update
    void Awake()
    {
        instance = this;

        bulletList = new List <GameObject>(amount);

        for (int i = 0; i < amount; i++)
        {
            GameObject pfabInstance = Instantiate(bulletPfab);
            pfabInstance.transform.SetParent(transform);
            pfabInstance.SetActive(false);
            bulletList.Add(pfabInstance);
        }
    }
Esempio n. 26
0
 // Start is called before the first frame update
 void Awake()
 {
     instance = this;
     Pasteles = new List <MunicionInfo>(municiPastel);
     for (int i = 0; i < municiPastel; i++)
     {
         MunicionInfo PPrefab;
         PPrefab.prefab = Instantiate(PastelazoPrefab);
         PPrefab.prefab.transform.SetParent(transform);
         PPrefab.prefab.SetActive(false);
         PPrefab.scriptPastelazoPW = PPrefab.prefab.GetComponent <PastelazoPW>();
         Pasteles.Add(PPrefab);
     }
 }
Esempio n. 27
0
    private void Awake()
    {
        instance = this;

        bullets = new List <GameObject>(bulletAmount);
        for (int i = 0; i < bulletAmount; i++)
        {
            GameObject prefabInstance = Instantiate(bulletPrefab);
            prefabInstance.transform.SetParent(transform);
            prefabInstance.SetActive(false);

            bullets.Add(prefabInstance);
        }
    }
Esempio n. 28
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         ObjectPoolingManager.Instance.GetBullet();
         if (ammo > 0)
         {
             ammo--;
             GameObject bulletObject = ObjectPoolingManager.Instantiate(bulletPrefab);
             bulletObject.transform.position = playerCamera.transform.position + playerCamera.transform.forward;
             bulletObject.transform.forward  = playerCamera.transform.forward;
         }
     }
 }
Esempio n. 29
0
    void OnEnable()
    {
        if (platformGroups.Count < 1)
        {
            throw new ArgumentOutOfRangeException("There must be at least two platform position groups.");
        }

        _playerController     = GameManager.instance.player;
        _objectPoolingManager = ObjectPoolingManager.Instance;

        for (int i = 0; i < platformGroups.Count; i++)
        {
            platformGroups[i].gameObjects = new List <GameObjectContainer>();
        }

        int   index = 0;
        float twoPi = Mathf.PI * 2f;

        for (float angle = 0f; angle < twoPi; angle += twoPi / totalPlatforms)
        {
            Quaternion q = Quaternion.AngleAxis(angle, Vector3.forward);

            Vector3 rotated = new Vector3(width * Mathf.Cos(angle), height * Mathf.Sin(angle), 0.0f);
            rotated = q * rotated + this.transform.position;

            GameObject platform = null; // note: we do allow null game objects in case it is a wheel with a single platform switch group
            if (platformGroups[index].disabledGameObject != null)
            {
                platform = _objectPoolingManager.GetObject(platformGroups[index].disabledGameObject.name);
                platform.transform.position = rotated;
            }
            platformGroups[index].gameObjects.Add(new GameObjectContainer()
            {
                GameObject = platform, Angle = angle
            });

            index = index < platformGroups.Count - 1 ? index + 1 : 0;
        }

        if (platformGroupStartIndex < 0 || platformGroupStartIndex >= platformGroups.Count)
        {
            SwitchGroups(0);
        }
        else
        {
            SwitchGroups(platformGroupStartIndex);
        }

        _playerController.OnJumpedThisFrame += _playerController_OnJumpedThisFrame;
    }
    // Start is called before the first frame update
    void Awake()
    {
        instance = this;

        projectiles = new List <GameObject>(projAmount);
        for (int i = 0; i < projAmount; i++)
        {
            GameObject prefabInstance = Instantiate(projPrefab);
            prefabInstance.transform.SetParent(transform);
            prefabInstance.SetActive(false);

            projectiles.Add(prefabInstance);
        }
    }