Пример #1
0
    public override void _Ready()
    {
        scoreController = (ScoreController)GetNode("/root/GameController/CurrentSceneParent/Game/MarginContainer/HBoxContainer/VBoxContainer");

        Random rand = new Random();

        ColorRect   background  = (ColorRect)GetNode("Background");
        PackedScene bubbleScene = (PackedScene)ResourceLoader.Load("res://scenes/Bubble.tscn");

        GD.Print("Setup");

        for (int y = 0; y < gridHeight; y++)
        {
            for (int x = 0; x < gridWidth; x++)
            {
                bubbleList.Add((Bubble)bubbleScene.Instance());
                background.AddChild(bubbleList[bubbleList.Count - 1]);

                String index = ((y * gridWidth) + x + 1).ToString();
                bubbleList[bubbleList.Count - 1].SetName("Bubble" + index);
                bubbleList[bubbleList.Count - 1].SetGridLocation(x + 1, y + 1);
            }
        }

        foreach (Bubble bubble in bubbleList)
        {
            bubble.SetupNeighbors();
        }
    }
Пример #2
0
        public CharacterPlayer(int x, int y, Level level)
            : base(x, y, level)
        {
            if (level != null)
            {
                _camera         = new Camera();
                _camera.Current = true;

                switch (Type)
                {
                case CharacterType.Player_East:
                    _camera.Transform = Transform.Identity.Rotated(Vector3.Up, Mathf.Pi * -0.5f);
                    break;

                case CharacterType.Player_West:
                    _camera.Transform = Transform.Identity.Rotated(Vector3.Up, Mathf.Pi * 0.5f);
                    break;

                case CharacterType.Player_South:
                    _camera.Transform = Transform.Identity.Rotated(Vector3.Up, Mathf.Pi * -1.0f);
                    break;
                }

                _moveSpeed = Level.CellSize * 200.0f;
                _turnSpeed = 3f;

                _useRay               = new RayCast();
                _useRay.Enabled       = true;
                _useRay.ExcludeParent = true;
                _useRay.CastTo        = Vector3.Forward * (Level.CellSize * 0.5f);
                _useRay.CollisionMask = (uint)(
                    Level.CollisionLayers.Characters |
                    Level.CollisionLayers.Static |
                    Level.CollisionLayers.Walls);
                _useRay.AddException(this);

                _camera.AddChild(_useRay);

                _flashDuration = 0.5f;

                _flashRect                  = new ColorRect();
                _flashRect.MouseFilter      = Control.MouseFilterEnum.Ignore;
                _flashRect.Color            = new Color(0.75f, 0.75f, 0f, 1f);
                _flashRect.AnchorTop        =
                    _flashRect.AnchorLeft   = 0f;
                _flashRect.AnchorRight      =
                    _flashRect.AnchorBottom = 1f;
                _flashRect.SetAsToplevel(true);
                _flashRect.ShowOnTop = true;
                _flashRect.Visible   = false;

                _flashTween = new Tween();
                _flashTween.Connect("tween_all_completed", this, "OnFlashTweenCompleted");
                _flashRect.AddChild(_flashTween);

                _flashCanvas = new CanvasLayer();
                _flashCanvas.AddChild(_flashRect);

                _camera.AddChild(_flashCanvas);

                AddChild(_camera);

                SetProcess(true);
                SetPhysicsProcess(true);
            }
        }