示例#1
0
        public static State ConvertState(UState obj, UClass containingClass = null, bool decompileBytecode = true, FileLib lib = null)
        {
            if (containingClass is null)
            {
                ExportEntry classExport = obj.Export.Parent as ExportEntry;
                while (classExport != null && !classExport.IsClass)
                {
                    classExport = classExport.Parent as ExportEntry;
                }

                if (classExport == null)
                {
                    throw new Exception($"Could not get containing class for state {obj.Export.ObjectName}");
                }

                containingClass = classExport.GetBinaryData <UClass>();
            }
            // TODO: labels

            State parent = null;

            //if the parent is not from the same class, then it's overriden, not extended
            if (obj.SuperClass != 0 && obj.SuperClass.GetEntry(obj.Export.FileRef).Parent == obj.Export.Parent)
            {
                parent = new State(obj.SuperClass.GetEntry(obj.Export.FileRef).ObjectName.Instanced, null, default, null, null, null, null, null, null);
示例#2
0
 public void SetState(Type stateType, TParamStruct parameters)
 {
     // Set the state to a certain state type
     if (ActiveState != null)
     {
         ActiveState.Exit(parameters);
     }
     ActiveState = States[typeMap[stateType]];
     ActiveState.Enter(parameters);
 }
示例#3
0
    public UStateMachine(TParamStruct p, params UState <TParamStruct>[] states)
    {
        States = states;

        typeMap = new Dictionary <Type, int>();

        for (int i = 0; i < states.Length; i++)
        {
            states[i].Parent = this;
            typeMap.Add(states[i].GetType(), i);
        }

        ActiveState = states[0];
        ActiveState.Enter(p);
    }
示例#4
0
        private CardUnit(Scene scene, Card card)
        {
            Card  = card;
            Scene = scene;

            HaveBody        B;
            HaveBox         haveBox;
            VideoInCard     videoInCard;
            CheckedSymbol   ChS;
            DragAndDrop     DaD;
            Moveable        M;
            HiderShower     ShowComp;
            CardShower      cardShower;
            OLDInGameStruct InGS;
            UState          uState;
            Hit             hit;

            B           = new HaveBody("HaveBody", this, new CardUnitElement());
            videoInCard = new VideoInCard("VideoInCard", this, ((CardUnitElement)B.Body).ContentGrid);

            if (System.IO.File.Exists(card.ImageAddress) || Miscellanea.UrlExists(card.ImageAddress))
            {
                if (Path.GetExtension(card.ImageAddress) == ".gif")
                {
                    var image = new BitmapImage();
                    image.BeginInit();
                    image.UriSource = new Uri(card.ImageAddress);
                    image.EndInit();
                    ImageBehavior.SetAnimatedSource(((CardUnitElement)B.Body).Img, image);
                    GifController = ImageBehavior.GetAnimationController(((CardUnitElement)B.Body).Img);
                }
                else if (Path.GetExtension(card.ImageAddress) == ".wmv" || Path.GetExtension(Card.ImageAddress) == ".avi")
                {
                    ((CardUnitElement)B.Body).Img.Visibility = System.Windows.Visibility.Collapsed;
                    videoInCard.Run(card.ImageAddress);
                }
                else
                {
                    ((CardUnitElement)B.Body).Img.Source = PictHelper.GetBitmapImage(new Uri(card.ImageAddress));
                }
            }
            else
            {
                if (System.IO.File.Exists(Sets.Settings.GetInstance().DefaultImage))
                {
                    ((CardUnitElement)B.Body).Img.Source =
                        PictHelper.GetBitmapImage(new Uri(Sets.Settings.GetInstance().DefaultImage));
                }
                else
                {
                    MessageBox.Show("Файл изображения не найден:  " + card.ImageAddress);
                }
            }

            ShowComp      = new HiderShower("HiderShower", this);
            cardShower    = new CardShower("CardShower", this);
            InGS          = new OLDInGameStruct("InGameStruct", this, Scene);
            hit           = new Hit("Hit", this);
            uState        = new UState("UState", this);
            uState.newOld = NewOld.New;
            ShowComp.Hide();

            B.Body.PreviewMouseLeftButtonDown += Body_PreviewMouseLeftButtonDown;
        }