Exemple #1
0
    // public ResourcePrizeControl planetResourcePrefab;

    // Use this for initialization
    void Start()
    {
        anim = GetComponent <Animator>();

        CSP = FindObjectOfType <CommonSceneParams>();
        //currSceneLevel = CSP.currLevel;
        //Debug.Log("ConstGameCtrl.instance: " + ConstGameCtrl.instance);
        currSceneLevel = ConstGameCtrl.instance.CurrentLevel;

        myDamagable              = gameObject.GetComponent <Damagable>();
        myDamagable.deathDel     = OnPlanetTreasure;
        myDamagable.planetChHlth = OnPlasmaWound;

        myDamagable.currentHealth = 5; // mePlanet.planetHealth;
        myDamagable.currentShield = 0;
        myDamagable.myObject      = gameObject;

        ObstacleBehaviour OB = gameObject.GetComponent <ObstacleBehaviour>();

        if (OB)
        {
            myRadii = OB.GetMyRadii();
        }
        else
        {
            myRadii = 0;
        }
    }
    protected void SpawnNewObstacle(
        Mesh obstacleMesh,
        float passDistance,
        Material obstacleMaterial,
        Color materialColor)
    {
        // instantiating the mesh object and parenting it to the unit
        GameObject obstacleGO = new GameObject("Obstacle");

        //obstacleGO.transform.SetParent(transform);
        obstacleGO.transform.position = transform.position;
        obstacleGO.transform.Rotate(new Vector3(0f, 0f, Random.Range(0f, 359f)));

        MeshFilter        obstacleMeshFilter   = obstacleGO.AddComponent <MeshFilter>();
        MeshRenderer      obstacleMeshRenderer = obstacleGO.AddComponent <MeshRenderer>();
        MeshCollider      obstacleMeshCollider = obstacleGO.AddComponent <MeshCollider>();
        ObstacleBehaviour obstacleBehaviour    = obstacleGO.AddComponent <ObstacleBehaviour>();

        obstacleGO.layer = LayerMask.NameToLayer("Obstacles");
        obstacleBehaviour.Init(passDistance);



        //----------------
        // applying mesh and material
        obstacleMeshFilter.mesh = obstacleMesh;
        // obstacleMeshFilter.mesh.RecalculateNormals();
        obstacleMeshRenderer.material       = obstacleMaterial;
        obstacleMeshRenderer.material.color = materialColor;

        obstacleMeshCollider.sharedMesh = obstacleMeshFilter.mesh;
    }
Exemple #3
0
    void Create()
    {
        // Only run if this object is active
        if (gameObject.activeInHierarchy)
        {
            float x = Random.Range(bounds.xMin, bounds.xMax);
            float y = Random.Range(bounds.yMin, bounds.yMax);

            // Create a new instance of Boost or Asteroid, randomise its starting position and rotation
            GameObject go;

            if (Random.value >= 0.5f)
            {
                go = Instantiate(boost, new Vector3(x, y, spawnZ), Quaternion.identity) as GameObject;
            }
            else
            {
                go = Instantiate(asteroid, new Vector3(x, y, spawnZ), Quaternion.identity) as GameObject;
            }

            ObstacleBehaviour behaviour = go.GetComponent <ObstacleBehaviour> ();
            behaviour.controller = controller;

            // Sets a timer to call this function again sometime between 1.5 ans 5.5 seconds
            Invoke("Create", Random.Range(1.5f, 5.5f));
        }
    }
    public static void AddScore(int amount)
    {
        score += amount;
        float playerForwardVelocity = PlayerController.GetForwardVelocity();

        if (playerForwardVelocity < 70f)
        {
            PlayerController.SetForwardVelocity(playerForwardVelocity * 1.25f * totalMult);
        }

        PlayerController.SetAngularVelocity(PlayerController.GetAngularVelocity() * 1.01f * totalMult);

        float spawnInterval = ObstacleSpawner.GetSpawnInterval();

        if (spawnInterval > 10f)
        {
            ObstacleSpawner.SetSpawnInterval(spawnInterval - 0.1f * totalMult);
        }

        float holeRatioMin = ObstacleSpawner.GetHoleMin();
        float holeRatioMax = ObstacleSpawner.GetHoleMax();

        if (holeRatioMin > 0.2f)
        {
            ObstacleSpawner.SetHoleMin(holeRatioMin - 0.05f);
            ObstacleSpawner.SetHoleMax(holeRatioMax - 0.05f);
        }
        float rotationMultiplier = ObstacleBehaviour.GetRotationMultiplier();

        if (rotationMultiplier < 50.0f)
        {
            ObstacleBehaviour.SetRotationMultiplier(rotationMultiplier + 0.05f * totalMult);
        }
    }
Exemple #5
0
 // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
 override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     beh = animator.GetComponent <ObstacleBehaviour>();
     beh.MobileSpeedX        = 0;
     beh.movementOffsetRight = 0;
     beh.movementOffsetLeft  = 0;
     beh.body.velocity       = Vector3.zero;
 }
Exemple #6
0
    public BehaviourManager(IUpdateManager updateManager, IObjectStorage objectStorage)
    {
        _updateManager = updateManager;
        _objectStorage = objectStorage;

        _unitBehaviours    = new UnitBehaviours(_objectStorage);
        _bulletBehaviours  = new BulletBehaviours(_objectStorage);
        _bonusBehaviour    = new BonusBehaviour(_objectStorage);
        _upgradeBehaviours = new UpgradeBehaviours(_objectStorage);
        _obstacleBehaviour = new ObstacleBehaviour(_objectStorage);

        _updateManager.AddUpdatable(this);
    }
Exemple #7
0
    public void SpawnObstacles()
    {
        obstacles = new List <ObstacleBehaviour>();
        for (int i = 0; i < App.gameManager.gridSize; i++)
        {
            ObstacleBehaviour oX = Instantiate(obstaclePrefab, new Vector3(10, 0.8f, -1.1f + i * 1.1f), Quaternion.identity, inGameParent);
            oX.Init(Vector3.right, true);
            obstacles.Add(oX);

            ObstacleBehaviour oZ = Instantiate(obstaclePrefab, new Vector3(-1.1f + i * 1.1f, 0.8f, 10), Quaternion.identity, inGameParent);
            oZ.Init(Vector3.forward, false);
            obstacles.Add(oZ);
        }
    }
    //---------------------------
    void UpdateRadius()
    {
        RaycastHit hit;
        LayerMask  layerMask = 1 << LayerMask.NameToLayer("Obstacles");

        if (Physics.Raycast(new Vector3(0f, 0f, playerPositionZ), Vector3.forward, out hit, 100.0f, layerMask))
        {
            ObstacleBehaviour hitObstacleBehaviour = hit.transform.GetComponent <ObstacleBehaviour>();
            if (hitObstacleBehaviour)
            {
                SetNewFlyingRadius(hitObstacleBehaviour.GetHoleCenterRadius());
                CameraController.SetNewBackgroundColor(hitObstacleBehaviour.GetInvertedColor());
            }
        }
    }
Exemple #9
0
        private void CreateModel()
        {
            GameObject child = ResourceManger.Instance.CreateGameObject(BuildingPrefab);

            if (child == null)
            {
                return;
            }

            child.AddComponent <BuildingModel> ();
            child.transform.position   = this.transform.position;
            child.transform.localScale = Tool.GetBuildingScale(TileSize, TileCount);
            child.name = "Model";
            child.transform.SetParent(this.transform);

            ObstacleBehaviour ob = child.AddComponent <ObstacleBehaviour> ();

            ob.Center = new Vector3(0, TileSize.Height * 0.25f, 0);
            ob.Size   = new Vector3(TileSize.Width * 0.5f, TileSize.Height * 0.5f, TileSize.Height * 0.5f);
        }
    //-------------------------
    public void StartNewGame()
    {
        DisableUI(mainMenuUIGroup);
        DisableUI(gameUIGroup);
        EnableUI(gameUI);

        playerController.SetVisible(false);
        playerController.transform.position = Vector3.zero;
        playerController.SetVisible(true);
        ObstacleSpawner.DestroyAllObstacles();
        ObstacleSpawner.StartSpawning();
        GameManager.ResetScore();
        ObstacleSpawner.SetSpawnInterval(80f);
        PlayerController.SetAngularVelocity(10f);
        PlayerController.SetAngularVelocity(10f);
        PlayerController.SetForwardVelocity(20f);
        ObstacleSpawner.SetHoleMin(0.6f);
        ObstacleSpawner.SetHoleMax(0.8f);
        ObstacleBehaviour.SetRotationMultiplier(100f);
        ObstacleSpawner.Reset();

        isGameRunning = true;
    }
Exemple #11
0
 // Use this for initialization
 void Awake()
 {
     instance = this;
 }