예제 #1
0
    public void LoadShip(Ship s)
    {
        Clear();
        ship = s;
        foreach (Part p in DesignManager.instance.GetAllParts())
        {
            GameObject g  = partIconPool.GetGameObject();
            PartIcon   pi = g.GetComponent <PartIcon>();
            pi.DisplayPart(p);
        }
        foreach (Hardpoint h in ship.hardpoints)
        {
            GameObject       g  = hardpointDisplayPool.GetGameObject();
            HardpointDisplay ha = g.GetComponent <HardpointDisplay>();

            DragDestination dd = g.GetComponent <DragDestination>();
            if (dd == null)
            {
                g.AddComponent <DragDestination>();
                g.GetComponent <DragDestination>().handler = this;
            }

            ha.DisplayHardpoint(h);
        }
    }
예제 #2
0
    public bool CanPlayCard(Card card, DragDestination destination)
    {
        bool canPlay     = true;
        bool canPayCosts = true;

        foreach (CardData.Cost cost in card.Data.Costs)
        {
            canPayCosts = canPayCosts && (resourceAmounts[cost.ResourceType] >= cost.Amount);
        }

        canPlay = canPlay && canPayCosts;

        if (destination.DestinationType == DragDestination.Type.UpgradeCard)
        {
            canPlay = canPlay && (card.Data.Upgrade != null);
        }

        int gainTotalSoldiersAmount = card.Data.Effects
                                      .Where(effect => effect.EffectType == CardData.Effect.Type.AddResources && effect.ResourceType == ResourceType.TotalSoldiers)
                                      .Sum(effect => effect.ResourceAmount);

        canPlay = canPlay && (resourceAmounts[ResourceType.SoldiersStorage] >= gainTotalSoldiersAmount);

        return(canPlay);
    }
 public bool PerformDrag(DragDestination sender)
 {
     if (ValidateDrag(sender) != null)
     {
         return(true);
     }
     return(false);
 }
 public int DraggingUpdated(DragDestination sender)
 {
     if (ValidateDrag(sender) != null)
     {
         return((int)DragOperation.Copy);
     }
     return((int)DragOperation.None);
 }
예제 #5
0
    void FindDestination(IInteractable obj)
    {
        Vector3 pos       = Vector3.zero;
        var     draggable = obj.GetComponent <IInteractable>();

        DisableCol(obj);
        if (draggable.destination != null)
        {
            currentDest = draggable.destination;

            if (draggable.destination.onDestination)
            {
                newPos = currentDest.snapPosition;
                newRot = currentDest.snapRot;

                if (Physics.Raycast(ray, out hit, GameSettings.instance.maxRayDist, defaultMask))
                {
                    if (Vector3.Distance(hit.point, currentDest.snapPosition) > 0.5f)
                    {
                        if (hit.transform.gameObject.tag.Equals("Surface"))
                        {
                            ShutOffDest(obj);
                            EnableCol();
                            MoveOnSurface(obj);
                        }
                        else
                        {
                            ShutOffDest(obj);
                            EnableCol();
                            MoveToHelper();
                        }
                    }
                }
                else
                {
                    ShutOffDest(obj);
                    EnableCol();
                    MoveToHelper();
                }
            }
            else
            {
                FindNearestPoint(obj);
            }
        }
        else if (Physics.Raycast(ray, out hit, GameSettings.instance.maxRayDist, destinationMask))
        {
            currentDest               = hit.transform.GetComponent <DragDestination>();
            draggable.destination     = currentDest;
            currentDest.onDestination = true;
            newPos = currentDest.snapPosition;
            newRot = currentDest.snapRot;
        }
        else
        {
            FindNearestPoint(obj);
        }
    }
예제 #6
0
 void ShutOffDest(IInteractable obj)
 {
     obj.destination = null;
     if (currentDest != null)
     {
         currentDest.onDestination = false;
         currentDest = null;
     }
 }
예제 #7
0
    public void DragInto(DragDestination destination)
    {
        destination.DragCard(this);

        hasBeenDropped = true;

        // Make the card non-interactable so that we can no longer drag it away
        this.GetComponent <Image>().raycastTarget = false;

        GameManager.Instance.ResolveCard(this, destination);
    }
        /// <summary>
        /// Initializes a new instance of the CTreeView<T> class.
        /// </summary>
        public CTreeView()
            : base()
        {
            suspendUpdateCount = 0;
            //InitializeComponent();
            //SuspendRecalculating = true;
            //DuringUpdating = true;
            //SuspendUpdate = true;
            BeginUpdate();
            Nodes         = new CTreeNodeCollection <T>(this);
            PathSeparator = @"\";
            //DragAndDrop = new DragAndDropView();
            AutoScroll = true;
            AllowDrop  = true;//?
            //DrawStyle = CTreeViewDrawStyle.Tree;
            ShowPlusMinus = true;
            ShowLines     = true;
            //ShowControls = CTreeViewShowControls.Automatically;
            ShowRootLines  = true;
            _selectedNodes = new List <CTreeNode>();

            RelocateCollapsing = true;
            SelectionMode      = CTreeViewSelectionMode.Multi;
            DragAndDropMode    = CTreeViewDragAndDropMode.ReplaceReorder;
            //DragAndDropFlag = false;
            IndentDepth            = 30;
            IndentWidth            = 10;
            selectionPen           = new Pen(Color.Black, 1.0F);
            selectionPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
            selectionBrush         = new SolidBrush(SystemColors.Highlight);
            _LinesPen           = new Pen(Color.Black, 1.0F);
            _LinesPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
            Bitmap imagePlus  = new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("CTreeView.Resources.plus.bmp"));
            Bitmap imageMinus = new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("CTreeView.Resources.minus.bmp"));

            PlusMinus       = new CTreeViewPlusMinus(imagePlus, imageMinus);
            dragDestination = new DragDestination(this);

            this.DoubleBuffered = true;
            //this.ResizeRedraw = true;
            //this.AutoScrollMinSize = new Size(0, 0);
            //DuringUpdating = false;
            //SuspendRecalculating = false;
            //SuspendUpdate = false;
            EndUpdate();
        }
 private string ValidateDrag(DragDestination sender)
 {
     Console.WriteLine("validatedrag");
     if (sender.Source != this)
     {
         Pasteboard pb = sender.Pasteboard;
         if (pb.Types.Length > 0)
         {
             foreach (string type in pb.Types)
             {
                 if (type.Equals(Pasteboard.Filenames))
                 {
                     return(type);
                 }
             }
         }
     }
     return(null);
 }
        public void ConcludeDrag(DragDestination sender)
        {
            string type = ValidateDrag(sender);

            if (type != null)
            {
                Pasteboard pb = sender.Pasteboard;

                string [] list = pb.ListForType(type);
                filename.Value = list [0];

                FileWrapper file = new FileWrapper(list [0]);

                iconwell.Image = file.Icon;
            }
            else
            {
                Console.WriteLine(".");
            }
        }
예제 #11
0
    public void ResolveCard(Card card, DragDestination destination)
    {
        // Pay costs
        foreach (CardData.Cost cost in card.Data.Costs)
        {
            SetResourceAmount(cost.ResourceType, resourceAmounts[cost.ResourceType] - cost.Amount);
        }

        // Resolve effects
        switch (destination.DestinationType)
        {
        case DragDestination.Type.PlayCard:
            foreach (CardData.Effect effect in card.Data.Effects)
            {
                switch (effect.EffectType)
                {
                case CardData.Effect.Type.AddResources:
                    SetResourceAmount(effect.ResourceType, resourceAmounts[effect.ResourceType] + effect.ResourceAmount);
                    break;
                }
            }
            break;

        case DragDestination.Type.CloneCard:
            deck.AddCard(card.Data);
            break;

        case DragDestination.Type.RemoveCard:
            break;

        case DragDestination.Type.Ritual:
            break;

        case DragDestination.Type.UpgradeCard:
            deck.AddCard(card.Data.Upgrade);
            break;
        }

        // Draw a new card
        deck.DrawCard();
    }
 public void DraggingExited(DragDestination sender)
 {
     // nop
 }