Example #1
0
 public ActionResult Create(CreatureViewModel creatureViewModel)
 {
     if (ModelState.IsValid)
     {
         try
         {
             _creatureManager.AddCreature(creatureViewModel);
         }
         catch (Exception ex)
         {
             return(RedirectToAction("Index", "Error", new { message = ex.Message, stackTrace = ex.StackTrace }));
         }
         return(RedirectToAction("Index"));
     }
     try
     {
         ViewBag.CreatureDiets = _creatureDietManager.RetrieveCreatureDietList();
         ViewBag.CreatureTypes = _creatureTypeManager.RetrieveCreatureTypeList();
         return(View(creatureViewModel));
     }
     catch (Exception ex)
     {
         return(RedirectToAction("Index", "Error", new { message = ex.Message, stackTrace = ex.StackTrace }));
     }
 }
Example #2
0
        private void performAdd()
        {
            if (validateInputs())
            {
                var creature = new Creature()
                {
                    CreatureID     = txtCreatureName.Text,
                    CreatureDietID = ((CreatureDiet)cboDiets.SelectedItem).CreatureDietID,
                    CreatureTypeID = ((CreatureType)cboTypes.SelectedItem).CreatureTypeID
                };

                try
                {
                    int result = _creatureManager.AddCreature(creature);
                    if (result != 1)
                    {
                        throw new ApplicationException("Creature was not added!");
                    }
                    MessageBox.Show("Creature was added!");
                    this.DialogResult = true;
                    this.Close();
                }
                catch (Exception ex)
                {
                    var message = ex.Message;
                    if (ex.InnerException != null)
                    {
                        message += "\n\n" + ex.InnerException.Message;
                    }
                    //have to display the error
                    MessageBox.Show(message, "Add Failed", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                }
            }
        }
    // when button is pressed
    public void OnButtonPressed(VirtualButtonBehaviour vbuttonObjCandle)
    {
        Creature candle = new Candle();

        candle.SpawnSelf(prefabCandle, theTrackable);

        CreatureManager.AddCreature(candle);

    }
        /// <summary>
        ///AddCreature 的测试
        ///</summary>
        public void AddCreatureTestHelper <T>()
            where T : BaseCreature
        {
            CreatureManager <T> target = new CreatureManager <T>(); // TODO: 初始化为适当的值
            long iCreatureId           = 0;                         // TODO: 初始化为适当的值
            T    creatureT             = default(T);                // TODO: 初始化为适当的值

            target.AddCreature(iCreatureId, creatureT);
            Assert.Inconclusive("无法验证不返回值的方法。");
        }
Example #5
0
 private void BornAvatar()
 {
     if (Constants.GAME_MODE)
     {
         Avatar        = new Avatar(CurrentLayer);
         AvatarBlockId = CurrentLayer.GetAvatarStartingBlockId();
         CreatureManager.AddCreature(Avatar, AvatarBlockId * Constants.MAP_BLOCK_SIZE, Point.Zero, CurrentLayer);
         LiveMap.Actualize();
     }
 }
Example #6
0
 void Triangulate(HexCell cell)
 {
     for (HexDirection d = HexDirection.NE; d <= HexDirection.NW; d++)
     {
         Triangulate(d, cell);
     }
     if (!cell.IsUnderwater && !cell.HasRiver)
     {
         features.AddFeature(cell, cell.Position);
     }
     if (!cell.IsUnderwater && !cell.HasRiver)
     {
         creatures.AddCreature(cell, cell.Position);
     }
 }
Example #7
0
    // when button is pressed
    public void OnButtonPressed(VirtualButtonBehaviour vButt2)
    {
        //Debug.Log("````````````````````````````````button pressed  " );
        Creature particle = new Particle();

        if (!particleOn)
        {
            particle = new Particle();
            particle.SpawnSelf(prefabParticle, theTrackable);
            CreatureManager.AddCreature(particle);
        }
        else
        {
            CreatureManager.RemoveCreature(particle);
        }

        CreatureManager.ChangeParticleState(particleOn);
    }
    // when button is pressed
    public void OnButtonPressed(VirtualButtonBehaviour vButt2)
    {
        Debug.Log("SpawnNewInsect.OnButtonPressed()");
        _audioSource.Play();

        //Debug.Log("````````````````````````````````button pressed  " );
        Insect newbug;

        // Uncomment to Randomize bugs
        // if (Random.value > 0.5f)
        if (true)
        {
            newbug = new Moth();                        // create new instance of flying insect
            newbug.SpawnSelf(prefabMoth, theTrackable); // spawn prefab so we can see this new bug
        }
        else
        {
            newbug = new Gnat();                        // create new instance of flying insect
            newbug.SpawnSelf(prefabGnat, theTrackable); // spawn prefab so we can see this new bug
        }

        CreatureManager.AddCreature(newbug);            // creature manager keeps track of all bugs
    }