Esempio n. 1
0
        public ServiceResult Update(Anatomy s)
        {
            if (s == null)
            {
                return(ServiceResponse.Error("Invalid Anatomy sent to server."));
            }

            AnatomyManager anatomyManager = new AnatomyManager(Globals.DBConnectionKey, this.GetAuthToken(Request));
            var            res            = anatomyManager.Get(s.UUID);

            if (res.Code != 200)
            {
                return(res);
            }

            var dbS = (Anatomy)res.Result;

            if (dbS.DateCreated == DateTime.MinValue)
            {
                dbS.DateCreated = DateTime.UtcNow;
            }
            dbS.Deleted   = s.Deleted;
            dbS.Name      = s.Name;
            dbS.Status    = s.Status;
            dbS.SortOrder = s.SortOrder;

            return(anatomyManager.Update(dbS));
        }
Esempio n. 2
0
        void anatomyList_ItemAdded(ButtonGrid arg1, ButtonGridItem arg2)
        {
            Anatomy anatomy = (Anatomy)arg2.UserObject; //Ok to access user object here since it is set during the add.
            Radian  theta   = sceneViewController.ActiveWindow.Camera.getFOVy();

            //Generate thumbnail
            AxisAlignedBox boundingBox = anatomy.WorldBoundingBox;
            Vector3        center      = boundingBox.Center;

            //PROBABLY DON'T NEED THIS, ASPECT IS A SQUARE
            float aspectRatio = (float)ThumbSize / ThumbSize;

            if (aspectRatio < 1.0f)
            {
                theta *= aspectRatio;
            }

            Vector3 translation = center;
            Vector3 direction   = anatomy.PreviewCameraDirection;

            translation += direction * boundingBox.DiagonalDistance / (float)Math.Tan(theta);

            LayerState layers = new LayerState(anatomy.TransparencyNames, 1.0f);

            buttonGridThumbs.itemAdded(arg2, layers, translation, center, anatomy);
        }
 private void fireDisplayAnatomy(Anatomy anatomy)
 {
     if (DisplayAnatomy != null)
     {
         DisplayAnatomy.Invoke(anatomy);
     }
 }
Esempio n. 4
0
        public void AnatomyManager_DeleteAnatomy()
        {
            AnatomyManager m = new AnatomyManager(new TreeMonDbContext(connectionKey));
            Anatomy        s = new Anatomy()
            {
                AccountId   = "a",
                Name        = "DELETERECORD",
                CreatedBy   = "TESTUSER",
                DateCreated = DateTime.UtcNow
            };

            m.Insert(s);

            //Test the delete flag
            Assert.IsTrue(m.DeleteAnatomy(s) > 0);
            m.GetAnatomy("DELETERECORD");
            Anatomy d = m.GetAnatomy("DELETERECORD");

            Assert.IsNotNull(d);
            Assert.IsTrue(d.Deleted == true);


            Assert.IsTrue(m.DeleteAnatomy(s, true) > 0);
            d = m.GetAnatomy("DELETERECORD");
            Assert.IsNull(d);
        }
Esempio n. 5
0
        public void Api_AnatomyController_Update_Anatomy()
        {
            TreeMonDbContext context = new TreeMonDbContext(connectionKey);
            Anatomy          mdl     = new Anatomy();

            mdl.AccountUUID = SystemFlag.Default.Account;
            mdl.Name        = Guid.NewGuid().ToString("N");
            mdl.UUID        = Guid.NewGuid().ToString("N");
            mdl.DateCreated = DateTime.Now;
            Assert.IsTrue(context.Insert <Anatomy>(mdl));

            mdl = context.GetAll <Anatomy>().FirstOrDefault(w => w.Name == mdl.Name);
            Anatomy pv = new Anatomy();

            pv.UUID        = mdl.UUID;
            pv.AccountUUID = mdl.AccountUUID;
            pv.Name        = mdl.Name;
            //~~~ Updatable fields ~~~

            string postData = JsonConvert.SerializeObject(pv);

            Task.Run(async() =>
            {
                ServiceResult res = await TestHelper.SentHttpRequest("POST", "api/Anatomy/Update", postData, _ownerAuthToken);
                Assert.IsNotNull(res);
                Assert.AreEqual(res.Code, 200);

                Anatomy dbAnatomy = context.GetAll <Anatomy>().Where(w => w.Name == mdl.Name).FirstOrDefault();
                Assert.IsNotNull(dbAnatomy);
            }).GetAwaiter().GetResult();
        }
Esempio n. 6
0
        public ServiceResult Update(Anatomy s)
        {
            if (s == null)
            {
                return(ServiceResponse.Error("Invalid Anatomy sent to server."));
            }

            AnatomyManager anatomyManager = new AnatomyManager(Globals.DBConnectionKey, Request.Headers?.Authorization?.Parameter);
            var            dbS            = (Anatomy)anatomyManager.GetBy(s.UUID);

            if (dbS == null)
            {
                return(ServiceResponse.Error("Anatomy was not found."));
            }

            if (dbS.DateCreated == DateTime.MinValue)
            {
                dbS.DateCreated = DateTime.UtcNow;
            }
            dbS.Deleted   = s.Deleted;
            dbS.Name      = s.Name;
            dbS.Status    = s.Status;
            dbS.SortOrder = s.SortOrder;


            return(anatomyManager.Update(dbS));
        }
Esempio n. 7
0
 private void toggleAnatomyTransparency(ButtonGridItem item)
 {
     if (item != null)
     {
         Anatomy selectedAnatomy = buttonGridThumbs.getUserObject(item);
         if (anatomyController.ShowPremiumAnatomy || selectedAnatomy.ShowInBasicVersion)
         {
             if (selectedAnatomy.CurrentAlpha >= 0.9999f)
             {
                 selectedAnatomy.smoothBlend(0.7f, MedicalConfig.CameraTransitionTime, EasingFunction.EaseOutQuadratic);
             }
             else if (selectedAnatomy.CurrentAlpha <= 0.00008f)
             {
                 selectedAnatomy.smoothBlend(1.0f, MedicalConfig.CameraTransitionTime, EasingFunction.EaseOutQuadratic);
             }
             else
             {
                 selectedAnatomy.smoothBlend(0.0f, MedicalConfig.CameraTransitionTime, EasingFunction.EaseOutQuadratic);
             }
         }
         else
         {
             showBuyMessage();
         }
     }
 }
Esempio n. 8
0
        public ServiceResult AddAnatomy(Anatomy s)
        {
            if (CurrentUser == null)
            {
                return(ServiceResponse.Error("You must be logged in to access this function."));
            }


            if (string.IsNullOrWhiteSpace(s.AccountUUID) || s.AccountUUID == SystemFlag.Default.Account)
            {
                s.AccountUUID = CurrentUser.AccountUUID;
            }

            if (string.IsNullOrWhiteSpace(s.CreatedBy))
            {
                s.CreatedBy = CurrentUser.UUID;
            }

            if (s.DateCreated == DateTime.MinValue)
            {
                s.DateCreated = DateTime.UtcNow;
            }

            AnatomyManager anatomyManager = new AnatomyManager(Globals.DBConnectionKey, Request.Headers?.Authorization?.Parameter);

            return(anatomyManager.Insert(s, true));
        }
        private int addAnatomyToIndex(Anatomy anatomy)
        {
            int index = anatomyList.Count;

            anatomyList.Add(anatomy);
            return(index);
        }
Esempio n. 10
0
        internal void showOnly(Anatomy anatomy)
        {
            LayerState currentLayers = LayerState.CreateAndCapture();

            TransparencyController.smoothSetAllAlphas(0.0f, MedicalConfig.CameraTransitionTime, EasingFunction.EaseOutQuadratic);
            anatomy.smoothBlend(1.0f, MedicalConfig.CameraTransitionTime, EasingFunction.EaseOutQuadratic);
            layerController.pushUndoState(currentLayers);
        }
Esempio n. 11
0
 public void addSelection(Anatomy anatomy)
 {
     if (anatomy != null)
     {
         selectedAnatomy.Add(anatomy);
         fireSelectedAnatomyChanged();
     }
 }
Esempio n. 12
0
 public void removeSelection(Anatomy anatomy)
 {
     if (anatomy != null)
     {
         selectedAnatomy.Remove(anatomy);
         fireSelectedAnatomyChanged();
     }
 }
Esempio n. 13
0
 /// <summary>
 /// Determine if the piece of anatomy that was clicked is the same as what was reclicked.
 /// </summary>
 /// <param name="anatomy"></param>
 /// <returns></returns>
 public bool clickedSameAnatomy(Anatomy anatomy)
 {
     if (anatomy == null && reclickAnatomy == null)
     {
         return(false);
     }
     return(reclickAnatomy == anatomy);
 }
Esempio n. 14
0
 private void addSingleAnatomy(Anatomy anatomy)
 {
     //Only add the anatomy if we haven't yet.
     if (!groupAnatomy.Contains(anatomy))
     {
         groupAnatomy.Add(anatomy);
     }
 }
Esempio n. 15
0
 public void setSelection(Anatomy anatomy)
 {
     selectedAnatomy.Clear();
     if (anatomy != null)
     {
         selectedAnatomy.Add(anatomy);
     }
     fireSelectedAnatomyChanged();
 }
Esempio n. 16
0
 private void initializeAnatomy(int idInput)
 {
     try {
         robot = gameObject.GetComponentInChildren <Anatomy>();
         robot.buildAnatomy(this, "robot", idInput);
     }
     catch (NullReferenceException) {
         Debug.Log("Unit initializeAnatomy failure, missing Anatomy component in children");
     }
 }
Esempio n. 17
0
        public void AnatomyManager_GetAnatomyBy()
        {
            AnatomyManager m = new AnatomyManager(new TreeMonDbContext(connectionKey));
            Anatomy        s = m.GetAnatomy("TESTRECORD");

            Assert.IsNotNull(s);
            Anatomy suid = m.GetAnatomyBy(s.UUID);

            Assert.IsNotNull(suid);
        }
Esempio n. 18
0
        public ServiceResult Delete(Anatomy s)
        {
            if (s == null || string.IsNullOrWhiteSpace(s.UUID))
            {
                return(ServiceResponse.Error("Invalid account was sent."));
            }

            AnatomyManager anatomyManager = new AnatomyManager(Globals.DBConnectionKey, Request.Headers?.Authorization?.Parameter);

            return(anatomyManager.Delete(s));
        }
Esempio n. 19
0
        public ServiceResult Delete(Anatomy s)
        {
            if (s == null || string.IsNullOrWhiteSpace(s.UUID))
            {
                return(ServiceResponse.Error("Invalid account was sent."));
            }

            AnatomyManager anatomyManager = new AnatomyManager(Globals.DBConnectionKey, this.GetAuthToken(Request));

            return(anatomyManager.Delete(s));
        }
Esempio n. 20
0
 /// <summary>
 /// Don't show locked anatomy in the restricted version.
 /// </summary>
 /// <param name="anatomy"></param>
 void anatomyController_DisplayAnatomy_Restricted(Anatomy anatomy)
 {
     if (anatomyController.ShowPremiumAnatomy || anatomy.ShowInBasicVersion)
     {
         //Add item
         ButtonGridItem anatomyItem = anatomyList.addItem("", anatomy.AnatomicalName, "", anatomy);
         if (anatomyController.SelectedAnatomy.isSelected(anatomy))
         {
             anatomyList.addSelected(anatomyItem);
         }
     }
 }
Esempio n. 21
0
        // Create some random monsters with random attack and defense values
        // and drop them all over the map in
        // random places.
        private void CreateMonster()
        {
            // number of monsters to create
            int numMonster = 10;

            // Create several monsters and
            // pick a random position on the map to place them.
            // check if the placement spot is blocking (e.g. a wall)
            // and if it is, try a new position
            for (int i = 0; i < numMonster; i++)
            {
                int monsterPosition = 0;
                while (CurrentMap.Tiles[monsterPosition].IsBlockingMove)
                {
                    // pick a random spot on the map
                    monsterPosition = rndNum.Next(0, CurrentMap.Width * CurrentMap.Height);
                }

                // Set the monster's new position
                // Note: this fancy math will be replaced by a new helper method
                // in the next revision of SadConsole
                var pos = new Point(monsterPosition % CurrentMap.Width, monsterPosition / CurrentMap.Height);

                Stat monsterStat = new Stat()
                {
                    Defense       = rndNum.Next(0, 10),
                    DefenseChance = rndNum.Next(0, 50),
                    Attack        = rndNum.Next(0, 10),
                    AttackChance  = rndNum.Next(0, 50),
                    Speed         = 1,
                    ViewRadius    = 7,
                    Health        = 10,
                    MaxHealth     = 10
                };

                // Need to refactor this so that it's simpler to create a monster, propably gonna use the example
                // of moving castle to make a static class containing blueprints on how to create the actors and items.
                Anatomy monsterAnatomy = new Anatomy();
                monsterAnatomy.SetRace(new Race("Debug Race"));

                Actor debugMonster = EntityFactory.ActorCreator(
                    pos,
                    new ActorTemplate("Debug Monster", Color.Blue, Color.Transparent, 'M',
                                      (int)MapLayer.ACTORS, monsterStat, monsterAnatomy, "DebugTest", 150, 60, "flesh"));

                debugMonster.AddComponent(new MoveAndAttackAI(debugMonster.Stats.ViewRadius));
                debugMonster.Inventory.Add(EntityFactory.ItemCreator(debugMonster.Position,
                                                                     new ItemTemplate("Debug Remains", Color.Red, Color.Black, '%', 1.5f, 35, "DebugRotten")));
                debugMonster.Anatomy.Limbs = LimbTemplate.BasicHumanoidBody(debugMonster);

                CurrentMap.Add(debugMonster);
            }
        }
        public IActionResult GetSpecificAnantomy(int id)
        {
            Anatomy anatomy = repo.GetSpecificAnatomy(id);

            if (anatomy == null)
            {
                return(BadRequest());
            }
            else
            {
                return(Ok(anatomy));
            }
        }
Esempio n. 23
0
        void anatomyController_SelectedAnatomyChanged(AnatomySelection anatomySelection)
        {
            Anatomy anatomy = anatomySelection.Anatomy;

            if (anatomy != null)
            {
                showWindow(anatomy, anatomyFinder.DisplayHintLocation, anatomyFinder.DeadZone);
            }
            else
            {
                closeUnpinnedWindow();
            }
        }
Esempio n. 24
0
        protected Actor(Color foreground, Color background, int glyph, string name) : base(foreground, background, glyph)
        {
            Name = name;

            anatomy = new Anatomy(this);

            anatomy.HardCodeHumanParts();

            NetBiologyValues();

            Health = HealthMax;

            SkinColor = foreground;
        }
Esempio n. 25
0
        void anatomyList_ItemChosen(ButtonGridItem item)
        {
            Anatomy anatomy = buttonGridThumbs.getUserObject(item);

            if (anatomyController.ShowPremiumAnatomy || anatomy.ShowInBasicVersion)
            {
                DisplayHintLocation = new IntVector2(anatomyWindowManager.determineContextWindowX(window.AbsoluteLeft, window.AbsoluteLeft + window.Width), item.AbsoluteTop);
                TriggeredSelection  = true;
                anatomyController.processSelection(anatomy, null);
            }
            else
            {
                showBuyMessage();
            }
        }
Esempio n. 26
0
        public void AnatomyManager_GetAnatomy()
        {
            AnatomyManager m  = new AnatomyManager(new TreeMonDbContext(connectionKey));
            ServiceResult  sr = m.Insert(new Anatomy()
            {
                AccountId   = "a",
                Name        = "ALPHA",
                DateCreated = DateTime.UtcNow
            }, false);

            Assert.AreEqual(sr.Code, 200, sr.Message);
            Anatomy s = m.GetAnatomy("ALPHA");

            Assert.IsNotNull(s);
        }
Esempio n. 27
0
        public ServiceResult GetAnatomyByName(string name)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                return(ServiceResponse.Error("You must provide a name for the Anatomy."));
            }

            AnatomyManager anatomyManager = new AnatomyManager(Globals.DBConnectionKey, Request.Headers?.Authorization?.Parameter);
            Anatomy        s = (Anatomy)anatomyManager.Get(name);

            if (s == null)
            {
                return(ServiceResponse.Error("Anatomy could not be located for the name " + name));
            }

            return(ServiceResponse.OK("", s));
        }
Esempio n. 28
0
        /// <summary>
        /// Shows all anatomy including locked anatomy
        /// </summary>
        /// <param name="anatomy"></param>
        void anatomyController_DisplayAnatomy(Anatomy anatomy)
        {
            //Add item
            ButtonGridItem anatomyItem = anatomyList.addItem("", anatomy.AnatomicalName, "", anatomy);

            if (!anatomyController.ShowPremiumAnatomy && !anatomy.ShowInBasicVersion)
            {
                IntCoord itemCoord          = anatomyItem.Coord;
                ImageBox lockedFeatureImage = (ImageBox)anatomyItem.createWidgetT("ImageBox", "ImageBox", 0, itemCoord.Bottom - lockSize, lockSize, lockSize, Align.Left | Align.Top, "LockedFeatureImage");
                lockedFeatureImage.NeedMouseFocus = false;
                lockedFeatureImage.setItemResource("LockedFeature");
            }
            if (anatomyController.SelectedAnatomy.isSelected(anatomy))
            {
                anatomyList.addSelected(anatomyItem);
            }
        }
Esempio n. 29
0
        public AnatomyContextWindow showWindow(Anatomy anatomy, IntVector2 position, IntCoord deadZone)
        {
            if (currentAnatomyWindow == null)
            {
                currentAnatomyWindow            = new AnatomyContextWindow(this, layerController);
                currentAnatomyWindow.SmoothShow = true;
            }
            currentAnatomyWindow.Anatomy = anatomy;
            currentAnatomyWindow.Visible = true;

            IntCoord windowCoord = new IntCoord(position.x, position.y, currentAnatomyWindow.Width, currentAnatomyWindow.Height);

            currentAnatomyWindow.Position = calculateChildPosition(anatomyFinder.DeadZone, windowCoord, anatomyFinder.TriggeredSelection);

            currentAnatomyWindow.ensureVisible();
            currentAnatomyWindow.bringToFront();

            return(currentAnatomyWindow);
        }
Esempio n. 30
0
 public void buildController(Unit unitInput)
 {
     /* initializeController ----- Initializes the controller, taking special input in the form
      * of keyword strings which are then fed into build net, and to the various sensors and
      * effectors to ensure they function as desired. */
     rootUnit  = unitInput;
     anatomy   = rootUnit.robot;
     sensors   = anatomy.gameObject.GetComponentsInChildren <Sensor>();
     effectors = anatomy.gameObject.GetComponentsInChildren <Effector>();
     foreach (Sensor sen in sensors)
     {
         sen.buildSensor(this);
     }
     foreach (Effector eff in effectors)
     {
         eff.buildEffector(this);
     }
     initializeNeuralNets();
 }