コード例 #1
0
    public void Create()
    {
        GameObject platform           = platforms[platforms.Count - 1];
        GameObject whereToInstantiate = platform.GetComponent <PlatformBehaviour>().whereToPlace;

        bool shufflin   = false;
        bool rotate     = false;
        int  givenColor = Random.Range(0, allMaterials.Count);

        PlatformColors color = (PlatformColors)givenColor;
        Material       mat   = allMaterials[givenColor];

        if (Random.Range(0, 100) < changePercentage)
        {
            int disp = Random.Range(0, 2);
            shufflin = disp == 0 ? true : false;
            rotate   = disp == 1 ? true : false;
        }

        if (Random.Range(0, 100) < changePercentage)
        {
            int disp = Random.Range(0, 2);
            shufflin = disp == 0 ? true : false;
            rotate   = disp == 1 ? true : false;
        }

        GameObject        platInstantiation = Instantiate(platformPrefab);
        PlatformBehaviour behaviour         = platInstantiation.GetComponent <PlatformBehaviour>();

        behaviour.SetUp(rotate, shufflin, mat, color);
        platInstantiation.transform.position = whereToInstantiate.transform.position;
        platforms.Add(platInstantiation);
    }
コード例 #2
0
    void GroundCheck()
    {
        Vector2[]      points = { pointLeft, pointCenter, pointRight };
        RaycastHit2D[] hits2D = new RaycastHit2D[points.Length];
        grounded = false;

        for (int i = 0; i < points.Length; i++)
        {
            hits2D[i] = Physics2D.Raycast(points[i], Vector3.down, minDistance);

            if (hits2D[i])
            {
                // Debug.Log (hits2D[i].collider.name);
                PlatformBehaviour behaviour = hits2D[i].collider.GetComponent <PlatformBehaviour>();
                if (speed.y < 0)
                {
                    transform.position = (transform.position + (Vector3.down * minDistance));
                    // Debug.Log algo
                    speed.y = 0;
                    if (behaviour != null)
                    {
                        behaviour.OnPlatformStep(gameObject);
                    }
                }
                grounded = true;
                break;
            }
        }
    }
コード例 #3
0
        private PlatformBehaviour GetLong()
        {
            if (!_long)
            {
                _long = Resources.Load <PlatformBehaviour>(AssetsPaths.Platforms[PlatformType.Long]);
            }

            return(_long);
        }
コード例 #4
0
        private PlatformBehaviour GetShort()
        {
            if (!_short)
            {
                _short = Resources.Load <PlatformBehaviour>(AssetsPaths.Platforms[PlatformType.Short]);
            }

            return(_short);
        }
コード例 #5
0
        private PlatformBehaviour GetMedium()
        {
            if (!_medium)
            {
                _medium = Resources.Load <PlatformBehaviour>(AssetsPaths.Platforms[PlatformType.Medium]);
            }

            return(_medium);
        }
コード例 #6
0
 void OnTriggerExit2D(Collider2D other)
 {
     if (!other.CompareTag("Player"))
     {
         return;
     }
     PlatformBehaviour.SetPlatformTrigger(false);
     allowClimb = false;
 }
コード例 #7
0
 void OnTriggerStay2D(Collider2D other)
 {
     if (!other.CompareTag("Player"))
     {
         return;
     }
     PlatformBehaviour.SetPlatformTrigger(true);
     allowClimb = true;
 }
コード例 #8
0
ファイル: PlatformFactory.cs プロジェクト: Apeksi1990/module2
    private PlatformBehaviour GetMainPlatform()
    {
        if (!_mainPlatform)
        {
            _mainPlatform =
                Resources.Load <PlatformBehaviour>
                    (AssetsPath.Platforms[PlatformType.Main]);
        }

        return(_mainPlatform);
    }
コード例 #9
0
    private PlatformBehaviour GetMovePlatform()
    {
        if (!_MovePlatform)
        {
            _MovePlatform =
                Resources.Load <PlatformBehaviour>
                    (AssetsPath.Platforms[PlatformType.Move]);
        }

        return(_MovePlatform);
    }
コード例 #10
0
    private PlatformBehaviour GetAutumnHillPlatform()
    {
        if (!_AutumnHillPlatform)
        {
            _AutumnHillPlatform =
                Resources.Load <PlatformBehaviour>
                    (AssetsPath.Platforms[PlatformType.AutumnHill]);
        }

        return(_AutumnHillPlatform);
    }
コード例 #11
0
    private PlatformBehaviour GetBevelRightPlatform()
    {
        if (!_BevelRightPlatform)
        {
            _BevelRightPlatform =
                Resources.Load <PlatformBehaviour>
                    (AssetsPath.Platforms[PlatformType.BevelRight]);
        }

        return(_BevelRightPlatform);
    }
コード例 #12
0
ファイル: CollisionTrigger2D.cs プロジェクト: Landwehr/Solilo
    void OnTriggerEnter2D(Collider2D other)
    {
        MostRecentEvent = Event.Enter;

        if (other.tag == "Platform")
        {
            spriteRenderer = other.gameObject.GetComponent <SpriteRenderer>();
            ChangeSprite();

            GetComponent <AudioSource>().Play();
            p = other.GetComponent <PlatformBehaviour>();
            p.boyTrue();
        }
    }
コード例 #13
0
    public void Generate()
    {
        _root = new GameObject("Root").transform;
        GeneratePlatform(_firstPlatform);
        for (var i = 1; i <= _countPlatform; i++)
        {
            PlatformData platform = _platforms[Random.Range(0, _platforms.Length)];
            GeneratePlatform(platform);
        }

        if (_isGenerateLastPlatform)
        {
            PlatformBehaviour child = _root.GetChild(_root.childCount - 1).GetComponent <PlatformBehaviour>();
            child.GenerateNewPart();
        }
    }
コード例 #14
0
    private void GenerateTile()
    {
        var position = GenerateSpawnPoint();
        var platform = Instantiate(platformPrefab, this.transform.position, Quaternion.identity);

        platform.transform.localScale = new Vector3(currentBounds.x, 1, currentBounds.y);
        platform.transform.parent     = this.transform;
        if (isMovingX)
        {
            platform.SetConfig(gameState, new Vector3(-position.x, currentScore, alignementPos.z), isMovingX);
        }
        else
        {
            platform.SetConfig(gameState, new Vector3(alignementPos.x, currentScore, -position.y), isMovingX);
        }
        var mat = platform.GetComponent <MeshRenderer>().material = Instantiate(baseMat);

        mat.color    = colorPicker.GradientColor();
        lastPlatform = platform;
        cashedPlatforms.Add(platform);
    }
コード例 #15
0
    void OnTriggerEnter2D(Collider2D other)
    {
        MostRecentEvent = Event.Enter;

        if (other.tag == "Platform")
        {
            //other.renderer.material.color = Color.magenta;
            spriteRenderer = other.gameObject.GetComponent <SpriteRenderer>();
            ChangeSprite();

            p = other.GetComponent <PlatformBehaviour>();
            p.girlTrue();
        }

        /*
         * Met opzet disabled, omdat dit een issue met timing gaf nu dat de snelheid
         * van de girl kan varieren door de afstand tussen haar en de boy.
         */
        //if (other.tag == "EndBridge")
        //{
        //	EndElementBridge e = other.GetComponent<EndElementBridge>();
        //	e.girl = true;
        //}
    }
コード例 #16
0
    public void Dispatch(PlatformColors color)
    {
        if (!FindObjectOfType <CharacterController>().isGrounded)
        {
            return;
        }

        GameObject platform = platforms[0];

        if (platform && platform.GetComponent <PlatformBehaviour>().color != color)
        {
            FindObjectOfType <CharacterController>().stun();
            livesNumber -= 1;

            switch (livesNumber)
            {
            case 2:
                foreach (GameObject go in firstLive)
                {
                    go.SetActive(false);
                }
                break;

            case 1:
                foreach (GameObject go in secondLive)
                {
                    go.SetActive(false);
                }
                break;

            case 0:
                foreach (GameObject go in thirdLive)
                {
                    go.SetActive(false);
                }
                break;
            }

            if (livesNumber <= 0)
            {
                GameOver("BAD COLOR !", "Too bad...you missed it...");
                return;
            }
            return;
        }

        if (!hasStarted)
        {
            hasStarted = true;
        }

        platformCount++;
        HandlePlatforming();
        Create();
        platforms.RemoveAt(0);
        PlatformBehaviour platformBehave = platform.GetComponent <PlatformBehaviour>();

        FindObjectOfType <CharacterController>().jumpTo(platformBehave.whereToLand.transform);

        if (platformBehave.isRotating && timeRotate <= 0f)
        {
            Camera.main.transform.rotation = Quaternion.Euler(0, 0, 180);
            timeRotate += 5f;
        }

        if (platformBehave.isShuffling)
        {
            ShuffleButtons();
        }
    }