// Start is called before the first frame update
    void Start()
    {
        TimingObstacle.unUsedObstacles    = new List <TimingObstacle>();
        TimingObstacle.usedObstacles      = new List <TimingObstacle>();
        SimpleObstacle.usedObstacles      = new List <SimpleObstacle>();
        SimpleObstacle.unUsedObstacles    = new List <SimpleObstacle>();
        HorizontalCrawler.unUsedObstacles = new List <HorizontalCrawler>();
        HorizontalCrawler.usedObstacles   = new List <HorizontalCrawler>();
        WallObstacle.usedObstacles        = new List <WallObstacle>();
        WallObstacle.unUsedObstacles      = new List <WallObstacle>();



        for (int i = 0; i < numberObstaclesGenerated; i++)
        {
            TimingObstacle t = Instantiate <TimingObstacle>(timingObstacle, generatePos(rotationPoint.position.y), Quaternion.identity);
            TimingObstacle.unUsedObstacles.Add(t);
            t.SetRadius(towerDiameter);
            HorizontalCrawler h = Instantiate <HorizontalCrawler>(horizontalCrawler, generatePos(rotationPoint.position.y), Quaternion.identity);
            HorizontalCrawler.unUsedObstacles.Add(h);
            h.SetRadius(towerDiameter);
            WallObstacle w = Instantiate <WallObstacle>(wallObstacle, generatePos(rotationPoint.position.y), Quaternion.identity);
            WallObstacle.unUsedObstacles.Add(w);
            w.SetRadius(towerDiameter);
            SimpleObstacle s = Instantiate <SimpleObstacle>(simpleObstacle, generatePos(rotationPoint.position.y), Quaternion.identity);
            SimpleObstacle.unUsedObstacles.Add(s);
            s.SetRadius(towerDiameter);
        }

        generatedHeight = startHeigth;

        GenerateChunk();
    }
示例#2
0
    protected void CreateWallToObstacle(WallObstacle o)
    {
        Vector2             offset   = new Vector2(wallLengthDone, 0);
        Vector3             wallSize = new Vector3(wallThickness, wallHeight, o.bottomLeftAnchorPosition.x - wallLengthDone);
        AdvancedCubeBuilder b        = new AdvancedCubeBuilder(MaxSize, wallSize, offset, transform, m);

        HandleCreatedWall(b);
    }
示例#3
0
        protected WallObstacle UnpackWall()
        {
            WallObstacle wall = new WallObstacle();

            wall.Position = ReadVector3F();
            wall.Rotation = ReadFloat();
            wall.Size     = new Vector3F(0, ReadFloat(), ReadFloat());
            wall.Ricochet = (ReadByte() & Constants.RICOCHET) != 0;
            return(wall);
        }
示例#4
0
    public void OnTriggerEnter2D(Collider2D collision)
    {
        HealthBar    player1 = collision.GetComponent <HealthBar>();
        WallObstacle Wall    = collision.GetComponent <WallObstacle>();

        if (player1 != null)
        {
            player1.getHit();
            DestroyProjectile();
        }
        else if (Wall != null)
        {
            DestroyProjectile();
        }
    }
示例#5
0
    protected void CreateWallOverObstacle(WallObstacle o)
    {
        float upperYPos = Mathf.Clamp(o.bottomLeftAnchorPosition.y + o.obstacleSize.y, 0, wallHeight);

        if (upperYPos < wallHeight)
        {
            Vector2 offset   = new Vector2(wallLengthDone, upperYPos);
            Vector3 wallSize = new Vector3(
                wallThickness,
                wallHeight - upperYPos,
                o.bottomLeftAnchorPosition.x - wallLengthDone + o.obstacleSize.x);
            AdvancedCubeBuilder b = new AdvancedCubeBuilder(MaxSize, wallSize, offset, transform, m);
            HandleCreatedWall(b);
        }
    }
示例#6
0
    public void OnTriggerEnter2D(Collider2D collision)
    {
        Debug.Log("Hit");
        Enemy        enemy = collision.GetComponent <Enemy>();
        WallObstacle Wall  = collision.GetComponent <WallObstacle>();

        if (enemy != null)
        {
            enemy.getHit();
            DestroyProjectile();
        }
        else if (Wall != null)
        {
            DestroyProjectile();
        }
    }
示例#7
0
        public void Validate()
        {
            if (Objects.FindIndex((x) => x as WallObstacle != null) > 0 || WorldInfo.NoWalls)
            {
                return;
            }

            float wallHeight = 6.5f; // TODO, get from BZDB

            WallObstacle wall = new WallObstacle();

            wall.Position = new LinearMath.Vector3F(0, WorldInfo.Size, 0);
            wall.Rotation = LinearMath.TrigTools.ToRad(270);
            wall.Size     = new LinearMath.Vector3F(0, WorldInfo.Size, wallHeight);
            wall.Ricochet = false;
            Objects.Add(wall);

            wall          = new WallObstacle();
            wall.Position = new LinearMath.Vector3F(WorldInfo.Size, 0, 0);
            wall.Rotation = LinearMath.TrigTools.ToRad(180);
            wall.Size     = new LinearMath.Vector3F(0, WorldInfo.Size, wallHeight);
            wall.Ricochet = false;
            Objects.Add(wall);

            wall          = new WallObstacle();
            wall.Position = new LinearMath.Vector3F(0, -WorldInfo.Size, 0);
            wall.Rotation = LinearMath.TrigTools.ToRad(90);
            wall.Size     = new LinearMath.Vector3F(0, WorldInfo.Size, wallHeight);
            wall.Ricochet = false;
            Objects.Add(wall);

            wall          = new WallObstacle();
            wall.Position = new LinearMath.Vector3F(-WorldInfo.Size, 0, 0);
            wall.Rotation = LinearMath.TrigTools.ToRad(0);
            wall.Size     = new LinearMath.Vector3F(0, WorldInfo.Size, wallHeight);
            wall.Ricochet = false;
            Objects.Add(wall);
        }
示例#8
0
    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.CompareTag("Coin Pick Up"))
        {
            CoinPickUp script = other.GetComponent <CoinPickUp>();
            script.OnPickUp();
            score += script.score;
            UIManager.SetPlayerScoreText(score);
            if (score % 10 == 0)
            {
                PlayerDirectionController.increaseDeathCount();
            }
        }
        if (other.gameObject.CompareTag("Light Orb Pick Up"))
        {
            LightOrbPickUp script = other.GetComponent <LightOrbPickUp>();
            script.OnPickUp();
            GameStateController.SetPlayerBrightnessDiff(script.brightness);
        }

        /*if(other.gameObject.CompareTag("SpeedChange Pick Up"))
         * {
         *  SpeedChangePickUp script = other.GetComponent<SpeedChangePickUp>();
         *  script.OnPickUp();
         *  CachedSpeed = speed;
         *  speed = script.GetNewSpeed(speed);
         *  CurrentSpeedPowerupLength = SpeedPowerupLength;
         *  UIManager.SetPlayerSpeedText(speed);
         * }*/

        if (other.gameObject.CompareTag("Mirror"))
        {
            if (!other.gameObject.GetComponent <ReflectObject>().MirrorHit)
            {
                Vector3 ReflectionAngle = Vector3.Reflect(transform.forward, other.transform.forward);
                transform.forward = ReflectionAngle;
                other.gameObject.GetComponent <ReflectObject>().MirrorHit = true;
            }
        }
        if (other.gameObject.CompareTag("RefractionObject"))
        {
            float IndexOfIncidence  = 1;
            float IndexOfRefraction = 4;
            if (!other.gameObject.GetComponent <RefractObject>().MirrorHit)
            {
                Vector3 ReflectionAngle             = Vector3.Reflect(transform.forward, other.transform.forward);
                float   AngleBetweenReflectedPoints = Vector3.Angle(transform.forward, ReflectionAngle);
                float   AngleOfIncidence            = (180 - AngleBetweenReflectedPoints) / 2;
                Debug.Log(AngleOfIncidence);
                float   AngleOfRefraction          = Mathf.Asin(IndexOfIncidence * Mathf.Sin((AngleOfIncidence * Mathf.PI) / 180) / IndexOfRefraction);
                float   AngleOfRefractionInDegrees = (Mathf.Asin(AngleOfRefraction) * 180) / Mathf.PI;
                Vector3 N             = other.transform.forward;
                Vector3 s1            = transform.forward;
                Vector3 RefractionDir = (IndexOfIncidence / IndexOfRefraction) * (Vector3.Cross(N, Vector3.Cross(-N, s1))) - N * Mathf.Sqrt(1 - Mathf.Pow(IndexOfIncidence / IndexOfRefraction, 2) * Vector3.Dot(Vector3.Cross(N, s1), Vector3.Cross(N, s1)));
                transform.forward = RefractionDir;
                Debug.Log(AngleOfRefractionInDegrees);
                //Vector3 RefractionAngle = ;
                //transform.forward = ReflectionAngle;
                other.gameObject.GetComponent <RefractObject>().MirrorHit = true;
            }
        }
        if (other.gameObject.CompareTag("Wall"))
        {
            GameStateController.SetPlayerBrightnessDiff(-20);
            WallObstacle WallComponent = other.gameObject.GetComponent <WallObstacle>();
            if (WallComponent != null && WallComponent.RedirectPointTransform != null)
            {
                other.gameObject.GetComponent <WallObstacle>().WarpPlayerToRedirectPoint1();
            }
            else
            {
                GameStateController.OnPlayerLose();
            }
        }
        if (other.gameObject.CompareTag("Finish"))
        {
            GameStateController.OnPlayerWin();
            if (ProgressSaver != null)
            {
                ProgressSaver.GetComponent <SaveProgress>().SaveLevelProgress();
            }
        }
    }
示例#9
0
 protected void CreateWallsAroundObstacle(WallObstacle o)
 {
     CreateWallUnderObstacle(o);
     CreateWallOverObstacle(o);
 }