コード例 #1
0
        public override void Init()
        {
            base.Init();
            tank.SetUp();
            // Testing below
            tank2.SetUp();
            tank2.tankSpeed  = 2;
            tankAni.isActive = true;
            tankAni.images.Add($"{Files.dirImg}explosion2.png");
            tankAni.images.Add($"{Files.dirImg}explosion3.png");
            tankAni.AssignTextures();
            texture = tankAni.CurrentTexture();
            int gameCheck = string.Compare(Game.playerName, "");

            if (gameCheck == 0)
            {
                Game.playerName = "player";
            }
            tank.name      = Game.playerName;
            tank.nameColor = Color.BLUE;
            // Setting parallax up
            ParallaxData data = Parallax.LoadJson(LoadImagesLevel.parallaxImages);

            if (data.filePath == "")
            {
                data = Parallax.LoadJson(LoadImagesLevel.parallaxImages + "\\");
            }
            parallax.Init(data.filePath, data.offset, data.scale, data.startSpeed, data.increasedSpeed);
            ammoBox.Inits();
            tank.ammo = 1;
        }
コード例 #2
0
ファイル: Parallax.cs プロジェクト: FeboGameDeveloper/Pearl
        // Start is called before the first frame update
        protected void Start()
        {
            _parallaxDatas = new Dictionary <Transform, ParallaxData>();
            if (parallaxDictionary != null && _parallaxDatas != null)
            {
                foreach (var element in parallaxDictionary)
                {
                    Transform parent = element.Key;

                    if (parent != null)
                    {
                        var children = parent.GetComponentsInHierarchy <Transform>(true);

                        if (children == null || children.Count == 0)
                        {
                            children = ListExtend.CreateList(parent);
                        }

                        foreach (var tr in children)
                        {
                            if (tr == null)
                            {
                                continue;
                            }

                            var auxSpriteRenderer = tr.GetComponent <SpriteRenderer>();

                            ParallaxData data = new ParallaxData(tr.position, auxSpriteRenderer.bounds.size.x, element.Value, auxSpriteRenderer);
                            data.distance = CalculateDistance(data);
                            _parallaxDatas.Add(tr, data);
                        }
                    }
                }
            }
        }
コード例 #3
0
    public void Update()
    {
        Vector3 velocity = _Direction * _Speed * Time.deltaTime;

        for (int i = 0; i < _ParallaxObjects.Length; i++)
        {
            ParallaxData data = _ParallaxObjects[i];
            ObjectPool   pool = data._Object;
            pool.transform.position += velocity * data._SpeedRatio01;
        }
    }
コード例 #4
0
ファイル: Parallax.cs プロジェクト: FeboGameDeveloper/Pearl
        private void Setting()
        {
            for (int i = 0; i < _parallaxDatas.Count; i++)
            {
                var          element = _parallaxDatas.Keys;
                Transform    tr      = element.Get(i);
                ParallaxData data    = _parallaxDatas[tr];

                if (tr == null)
                {
                    continue;
                }

                if (needVisible && !data.isVisibile && data.spiteRenderer != null)
                {
                    if (!data.spiteRenderer.isVisible)
                    {
                        continue;
                    }
                    else
                    {
                        data.isVisibile   = true;
                        data.initPosition = tr.position;
                        data.distance     = CalculateDistance(data);

                        _parallaxDatas[tr] = data;
                    }
                }

                float dist  = CalculateDistance(data);
                float delta = dist - data.distance;

                data.distance      = dist;
                _parallaxDatas[tr] = data;

                tr.SetTranslationInUpdate(velocityParallax.normalized * delta, TimeType.Scaled, updateModes);

                if (isLoop)
                {
                    float temp = tr.position.x * (1 - data.parallaxEffect);

                    if (temp > data.initPosition.x + data.bound)
                    {
                        data.initPosition.x += data.bound;
                    }
                    else if (temp < data.initPosition.x - data.bound)
                    {
                        data.initPosition.x -= data.bound;
                    }

                    _parallaxDatas[tr] = data;
                }
            }
        }
コード例 #5
0
        // Sets the new parallax background
        public void NewBackGround()
        {
            parallax = new Parallax();
            ParallaxData data = Parallax.LoadJson(LoadImagesLevel.parallaxImages);

            if (data.filePath == "")
            {
                data = Parallax.LoadJson(LoadImagesLevel.parallaxImages + "\\");
            }

            parallax.Init(data.filePath, data.offset, data.scale, data.startSpeed, data.increasedSpeed);
        }
コード例 #6
0
    public GameObject ground;           //container for array of ground parallax layers


    GameObject makeSpriteObject(ParallaxData p)
    {
        GameObject     spriteObject = new GameObject();
        SpriteRenderer rend         = spriteObject.AddComponent <SpriteRenderer>();

        rend.sprite   = p.sprite;
        rend.drawMode = p.drawMode;
        rend.color    = p.spriteTint;
        rend.size     = p.size;

        return(spriteObject);
    }
コード例 #7
0
        public override void Init()
        {
            base.Init();
            losePos = new Vector2((int)textboxPos.x + 100, (int)textboxPos.y / 2);
            textBox.Init();
            ParallaxData data = Parallax.LoadJson(LoadImagesLevel.parallaxImages);

            if (data.filePath == "")
            {
                data = Parallax.LoadJson(LoadImagesLevel.parallaxImages + "\\");
            }
            parallax.Init(data.filePath, data.offset, data.scale, data.startSpeed, data.increasedSpeed);
        }
コード例 #8
0
        public override void Init()
        {
            base.Init();
            textBox.Init();
            // Setting stuff up for paralax
            ParallaxData data = Parallax.LoadJson(LoadImagesLevel.parallaxImages);

            if (data.filePath == "")
            {
                data = Parallax.LoadJson(LoadImagesLevel.parallaxImages + "\\");
            }
            parallax.Init(data.filePath, data.offset, data.scale, data.startSpeed, data.increasedSpeed);
        }