Exemple #1
0
    public void InitSpawnPoints()
    {
        SceneTree st = GetTree();

        Godot.Array actorSpawns = st.GetNodesInGroup("ActorSpawnPoint");

        this.actorSpawnPoints = new List <Vector3>();

        for (int i = 0; i < actorSpawns.Count; i++)
        {
            Spatial spawnPoint = actorSpawns[i] as Spatial;

            if (spawnPoint != null)
            {
                this.actorSpawnPoints.Add(spawnPoint.GetGlobalTransform().origin);
            }
        }

        Godot.Array itemSpawns = st.GetNodesInGroup("ItemSpawnPoint");
        this.itemSpawnPoints = new List <Vector3>();

        for (int i = 0; i < itemSpawns.Count; i++)
        {
            Spatial spawnPoint = itemSpawns[i] as Spatial;

            if (spawnPoint != null)
            {
                this.itemSpawnPoints.Add(spawnPoint.GetGlobalTransform().origin);
            }
        }
    }
        public void MakeInputMapper(string actionName)
        {
            HBoxContainer container = new HBoxContainer();

            //Label
            Label actionLabel = new Label();

            actionLabel.Valign = Label.VAlign.Center;
            actionLabel.Text   = "Controls." + actionName;
            actionLabel.AddChild(new Translator());
            container.AddChild(actionLabel);

            container.AddChild(ControlUtility.MakeHorizontalFiller());

            //Bound actions
            Godot.Array actionList = InputMap.GetActionList(actionName);

            foreach (object actionItem in actionList)
            {
                InputEvent inputAction = actionItem as InputEvent;
                MakeRebindActionButton(container, inputAction);
            }

            //Add new binding options if its not 2 there.
            if (actionList.Count < 2)
            {
                int difference = 2 - actionList.Count;
                for (int i = 0; i < difference; i++)
                {
                    MakeRebindActionButton(container, null);
                }
            }

            GetParent().CallDeferred("add_child", container);
        }
Exemple #3
0
 public static Godot.Array ToGDArray(this object[] array)
 {
     Godot.Array gdArray = new Godot.Array();
     foreach (object obj in array)
     {
         gdArray.Add(obj);
     }
     return(gdArray);
 }
Exemple #4
0
    void connectBouncersToSpawnedFlyable()
    {
        Godot.Array bouncers = GetTree().GetNodesInGroup(BOUNCERS_GROUP_ID);

        foreach (StaticBody2D bouncer in bouncers)
        {
            ((Flyable)currentlyAdded).ConnectBouncerSignal(bouncer);
        }
    }
Exemple #5
0
 public static Godot.Array MakeGDArray(params object[] array)
 {
     Godot.Array gdArray = new Godot.Array();
     foreach (object obj in array)
     {
         gdArray.Add(obj);
     }
     return(gdArray);
 }
Exemple #6
0
 public void OnBagUpdate()
 {
     Godot.Array previews = GetNode("PiecePreviews").GetChildren();
     for (int i = 0; i < previews.Count; i++)
     {
         PreviewRect preview = (PreviewRect)previews[i];
         preview.PieceType = board.BagGen.ElementAt(i).Type;
     }
 }
Exemple #7
0
    void connectBarriersWeakToSpawnedFlyable()
    {
        Godot.Array barriersWeak = GetTree().GetNodesInGroup(BARRIERS_WEAK_GROUP_ID);

        foreach (StaticBody2D barrier in barriersWeak)
        {
            ((Flyable)currentlyAdded).ConnectBarrierWeakSignal(barrier);
        }
    }
Exemple #8
0
    void connectBarriersStrongToSpawnedFlyable()
    {
        Godot.Array barriersStrong = GetTree().GetNodesInGroup(BARRIERS_STRONG_GROUP_ID);

        foreach (StaticBody2D barrier in barriersStrong)
        {
            ((Flyable)currentlyAdded).ConnectBarrierStrongSignal(barrier);
        }
    }
    public static List <System.Object> ArrayToList(Godot.Array array)
    {
        List <System.Object> ret = new List <System.Object>();

        while (array.Count > 0)
        {
            ret.Add(array[0]);
            array.RemoveAt(0);
        }
        return(ret);
    }
Exemple #10
0
    List <CollisionShape> GetCollisionShapes()
    {
        List <CollisionShape> shapes = new List <CollisionShape>();

        Godot.Array owners = GetShapeOwners();
        foreach (object owner in owners)
        {
            int            ownerInt = (int)owner;
            CollisionShape cs       = (CollisionShape)ShapeOwnerGetOwner(ownerInt);
            if (cs != null)
            {
                shapes.Add(cs);
            }
        }
        return(shapes);
    }
 public override void _Process(float delta)
 {
     if (active)
     {
         Godot.Array overlappingAreas = GetOverlappingAreas();
         if (overlappingAreas.Contains(Itsy.LIGHTCONE_AREA) && !wind)
         {
             Position += Velocity * 0.05F;
         }
         else
         {
             Position += Velocity;
         }
         if (overlappingAreas.Contains(Itsy.ITSY_AREA) && !wind)
         {
             Collide();
             Itsy.ITSY.Damage();
         }
     }
 }
Exemple #12
0
    public override void _Process(float delta)
    {
        if (food != null)
        {
            if (!food.rotten)
            {
                float       rotMultiplier   = 1;
                Godot.Array overlappingLeft = left.GetOverlappingAreas();

                if (overlappingLeft.Count > 0)
                {
                    Slot slotLeft = (Slot)overlappingLeft[0];
                    if (slotLeft.food != null)
                    {
                        if (slotLeft.food.rotten)
                        {
                            rotMultiplier = 2;
                        }
                    }
                }
                Godot.Array overlappingRight = right.GetOverlappingAreas();

                if (overlappingRight.Count > 0)
                {
                    Slot slotRight = (Slot)overlappingRight[0];
                    if (slotRight.food != null)
                    {
                        if (slotRight.food.rotten)
                        {
                            rotMultiplier = 2;
                        }
                    }
                }
                if (food != null)
                {
                    food.rotMultiplier = rotMultiplier;
                }
            }
        }
    }
Exemple #13
0
    public void SetCollision(bool val)
    {
        Godot.Array owners = GetShapeOwners();
        collisionDisabled = !val;
        if (area == null)
        {
            InitArea();
        }
        foreach (object owner in area.GetShapeOwners())
        {
            int            ownerInt = (int)owner;
            CollisionShape cs       = (CollisionShape)area.ShapeOwnerGetOwner(ownerInt);
            if (cs != null)
            {
                cs.Disabled = !val;
            }
        }

        foreach (object owner in owners)
        {
            int            ownerInt = (int)owner;
            CollisionShape cs       = (CollisionShape)ShapeOwnerGetOwner(ownerInt);
            if (cs != null)
            {
                cs.Disabled = !val;
            }
        }
        ContactMonitor = val;
        if (val)
        {
            ContactsReported = 10;
        }
        else
        {
            ContactsReported = 0;
        }
    }
Exemple #14
0
    void InitArea()
    {
        if (area != null)
        {
            return;
        }
        List <CollisionShape> shapes = GetCollisionShapes();

        this.area = new Area();
        CollisionShape areaShape = new CollisionShape();

        area.AddChild(areaShape);
        Godot.Array areaShapeOwners = area.GetShapeOwners();
        for (int i = 0; i < areaShapeOwners.Count; i++)
        {
            int ownerInt = (int)areaShapeOwners[i];
            for (int j = 0; j < shapes.Count; j++)
            {
                area.ShapeOwnerAddShape(ownerInt, shapes[i].Shape);
            }
        }
        area.Connect("body_entered", this, nameof(OnCollide));
        AddChild(area);
    }
Exemple #15
0
    public override void _Input(InputEvent @event)
    {
        Godot.Array areas = GetOverlappingAreas();
        if (areas.Count > 0)
        {
            OverSlot = (Slot)areas[0];
        }
        else
        {
            OverSlot = null;
        }
        if (@event.IsActionPressed("ui_mb_left"))
        {
            if (OverSlot != null && !OverSlot.disabled)
            {
                if (OverSlot.place == Slot.PLACE.PAN && food != null && food.rotten)
                {
                    placeErrorSound.Play();
                }
                else
                {
                    if (OverSlot.food != null && food == null)
                    {
                        food          = OverSlot.food;
                        OverSlot.food = null;
                        food.place    = Slot.PLACE.CURSOR;
                        lastSlot      = OverSlot;
                        pickupSound.Play();
                    }
                }
            }
        }
        if (@event.IsActionReleased("ui_mb_left"))
        {
            if (OverSlot != null && !OverSlot.disabled)
            {
                if (OverSlot.place == Slot.PLACE.PAN && food != null && food.rotten)
                {
                    placeErrorSound.Play();
                }
                else
                {
                    if (OverSlot.food == null && food != null)
                    {
                        OverSlot.Drop(food);
                        food = null;
                        if (OverSlot.place != Slot.PLACE.BIN)
                        {
                            placeSound.Play();
                        }
                    }
                    else if (OverSlot.food == null && food != null)
                    {
                        OverSlot.Drop(food);
                        food = null;
                        if (OverSlot.place != Slot.PLACE.BIN)
                        {
                            placeSound.Play();
                        }
                    }
                }
            }
            else if (OverSlot != null && OverSlot.disabled)
            {
                placeErrorSound.Play();
            }

            if (OverSlot == null && lastSlot != null && lastSlot.food == null && food != null)
            {
                placeErrorSound.Play();
                lastSlot.Drop(food);
                food     = null;
                lastSlot = null;
            }
        }
        //if(@event.IsActionPressed("ui_mb_right")){
        //    if (OverSlot != null && !OverSlot.disabled)
        //    {
        //        if (OverSlot.place == Slot.PLACE.PAN && food != null && food.rotten)
        //        {

        //        }
        //        else
        //        {
        //            if (OverSlot.food != null && food != null)
        //            {
        //                Food temp = food;
        //                food = OverSlot.food;
        //                food.place = Slot.PLACE.CURSOR;
        //                lastSlot = OverSlot;
        //                OverSlot.Drop(temp);

        //            }
        //        }
        //    }

        //}
    }
 // Create an array using a single value
 public static Godot.Array ArrayWrap(object obj)
 {
     Godot.Array arr = new Godot.Array();
     arr.Add(obj);
     return(arr);
 }
Exemple #17
0
 public static Godot.Array ToGDArray(this object obj)
 {
     Godot.Array gdArray = new Godot.Array();
     gdArray.Add(obj);
     return(gdArray);
 }