public void loadLevel(int artefactId)
    {
        Artefact selectedArtefact = SharedInfo.getCurrGame().getCollection().getArtefactById(artefactId);

        SharedInfo.getCurrGame().setCurrentArtefact(selectedArtefact);
        Application.LoadLevel(levelToLoad);
    }
Example #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,FileName,Description")] Artefact artefact)
        {
            if (id != artefact.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(artefact);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ArtefactExists(artefact.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(artefact));
        }
Example #3
0
 public virtual void HandleRequest(HttpListenerRequest request, HttpListenerResponse response)
 {
     if (request.Url.Segments.Length > 1)
     {
         if (string.Compare(request.Url.Segments[1], 0, "artefacts", 0, 9, true) == 0)
         {
             Artefact artefact = BsonSerializer.Deserialize <Artefact>(new JsonReader(new StreamReader(new BsonStreamAdapter(request.InputStream))));
             //(BsonDeserializationContext.Builder builder) =>
             //{
             //    builder.DynamicDocumentSerializer = ArtefactSerializer.Instance;
             //});
             Console.WriteLine(nameof(Service) + ": " + UriBase
                                                                           /*.TrimEnd('/') + '/' + string.Join("/", request.Url.Segments) + '/'*/
                               + Console.Out.NewLine + artefact.ToJson()); //.ToString());
             using (var writer = new StreamWriter(response.OutputStream))
             {
                 using (var bsonwriter = new JsonWriter(writer))
                 {
                     BsonSerializer.Serialize(bsonwriter, typeof(Artefact), artefact);
                 }
             }
             //response.StatusCode = 200;
             //response.OutputStream.Flush();
             //response.OutputStream.Close();
         }
     }
 }
Example #4
0
        public async Task <ActionResult <Artefact> > PostArtefact(Artefact artefact)
        {
            // it would be better design to just return id, but clients
            // may need owner username
            var curUser = await _userService.GetCurUser(HttpContext);

            _context.Add(artefact);

            artefact.CreatedAt = DateTime.UtcNow;
            // OwnerId is shadow property
            _context.Entry(artefact).Property("OwnerId").CurrentValue = curUser.Id;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (ArtefactExists(artefact.Id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            artefact.Owner = curUser;
            var artefactJson = _artefactConverter.ToJson(artefact);

            return(CreatedAtAction("GetArtefact", new { id = artefact.Id },
                                   artefactJson));
        }
Example #5
0
    public bool isCollected(Artefact artefact)
    {
        bool isCollected;

        collectionStatus.TryGetValue(artefact.getId(), out isCollected);
        return(isCollected);
    }
 /// <param name="artefact">The <see cref="Artefact"/> instance</param>
 /// <param name="baseLevel">The type to format the artefact string for</param>
 public static string GetString(Artefact artefact, Type artefactType)
 {
     object[] attrs = artefactType.GetCustomAttributes(typeof(ArtefactFormatAttribute), false);
     ArtefactFormatAttribute afsAttr = attrs.Length > 0 ?
         (ArtefactFormatAttribute)attrs[0] : new ArtefactFormatAttribute();
     return afsAttr.GetArtefactString(artefact);
 }
Example #7
0
 public Game(String XMLContent)
 {
     collection = new Collection (XMLContent);
     collectionStatus = new CollectionStatus(collection.getTotal());
     currentArtefact = null;
     artefactJustCollected = false;
 }
Example #8
0
 public Game(String XMLContent)
 {
     collection            = new Collection(XMLContent);
     collectionStatus      = new CollectionStatus(collection.getTotal());
     currentArtefact       = null;
     artefactJustCollected = false;
 }
Example #9
0
 public void DropArtefact(Artefact artefact, bool silence = true)
 {
     this.Inventory.DropArtefact(artefact);
     if (!silence)
     {
         Console.WriteLine($"--[Персонаж {this.Name} выбросил артефакт {artefact}]--");
     }
 }
Example #10
0
 public bool Equals(Artefact artefact)
 {
     if ((object)artefact == null)
     {
         return(false);
     }
     return((getName() == artefact.getName()) && (getId() == artefact.getId()));
 }
Example #11
0
        public async Task GetWinners([FromBody] dynamic data, int?id)
        {
            string   winner          = data.Winner;
            var      winningArtefact = new Artefact();
            DateTime timeJudgement   = DateTime.ParseExact((string)data.TimeOfPairing, "dd/MM/yyyy, HH:mm:ss", CultureInfo.InvariantCulture);
            int      elapsedTime     = (int)data.ElapsedTime;
            string   comment         = data.Comment;
            var      user            = GetCurrentUserAsync().Result.Id;
            Pairing  pairing         = new Pairing
            {
                ExperimentId = (int)id,
                Experiment   = await _context.Experiment.FirstOrDefaultAsync(m => m.Id == id),
                JudgeLoginID = user
            };
            List <ArtefactPairing> pairOfScripts = new List <ArtefactPairing>();
            string   scriptOne   = data.ArtefactPairings["item1"];
            Artefact artefactOne = await _context.Artefact
                                   .FirstOrDefaultAsync(m => m.FilePath == scriptOne);

            ArtefactPairing one = new ArtefactPairing
            {
                ArtefactId = artefactOne.Id,
                PairingId  = pairing.Id,
                Artefact   = artefactOne
            };
            string   scriptTwo   = data.ArtefactPairings["item2"];
            Artefact artefactTwo = await _context.Artefact
                                   .FirstOrDefaultAsync(m => m.FilePath == scriptTwo);

            ArtefactPairing two = new ArtefactPairing
            {
                ArtefactId = artefactTwo.Id,
                PairingId  = pairing.Id,
                Artefact   = artefactTwo
            };

            if (artefactOne.FilePath == winner)
            {
                winningArtefact = artefactOne;
            }
            else
            {
                winningArtefact = artefactTwo;
            }
            pairOfScripts.Add(one);
            pairOfScripts.Add(two);
            pairing.ArtefactPairings = pairOfScripts;
            pairing.Winner           = winningArtefact;
            pairing.TimeOfPairing    = timeJudgement;
            pairing.ElapsedTime      = elapsedTime;
            pairing.Comment          = comment;
            if (ModelState.IsValid)
            {
                _context.Update(pairing);
                await _context.SaveChangesAsync();
            }
        }
 /// <summary>
 /// Gets the artefact string.
 /// </summary>
 /// <returns>The formatted artefact string</returns>
 /// <param name="artefact">The <see cref="Artefact"/> instance</param>
 /// <param name="baseLevel">The distance from the most derived type, of the type to format the artefact string for</param>
 /// <param name="levelValid"><c>out</c> parameter that indicates if <paramref name="baseLevel"/> was valid (not higher than type inheritance depth)</param>
 public static string GetString(Artefact artefact, int baseLevel, out bool levelValid)
 {
     Type TArtefact = artefact.GetType();
     Type[] typeHeirarchy = _typeHeirarchyCache.ContainsKey(TArtefact) ?
         _typeHeirarchyCache[TArtefact]
         : _typeHeirarchyCache[TArtefact] = Artefact.GetTypeHeirarchy(TArtefact);
     levelValid = baseLevel < typeHeirarchy.Length ? true : false;
     return levelValid ? GetString(artefact, typeHeirarchy[baseLevel]) : string.Empty;
 }
Example #13
0
        public void WhenAddSameArtefactTwiceToPeer_ThrowsDuplicateKeyException()
        {
            var artefact = new Artefact(Artefact, MyId);

            MyAccount.Self.AddArtefact(artefact);

            var ex = Assert.Throws <DuplicateKey <ArtefactId> >(() => MyAccount.Self.AddArtefact(artefact));

            Assert.Contains($"{artefact.Id}", ex.Message);
        }
Example #14
0
    // Use this for initialization
    void Start()
    {
        game = SharedInfo.getCurrGame ();

        artefactId = game.getCollectionStatus ().getNextToCollect ();
        nextArtefactToCollect = game.getCollection ().getArtefactById (artefactId);

        GameObject.Find ("CluePanel").GetComponentsInChildren<Text>()[0].text = getTitleFromNumber(nextArtefactToCollect.getId() + 1);
        GameObject.Find ("CluePanel").GetComponentsInChildren<Text>()[1].text = nextArtefactToCollect.getClue ();
    }
 /// <summary>
 /// Gets the artefact string.
 /// </summary>
 /// <returns>The formatted artefact string</returns>
 /// <param name="artefact">The <see cref="Artefact"/> instance</param>
 public static string GetString(Artefact artefact)
 {
     StringBuilder sb = new StringBuilder(1024);
     string artefactString = string.Empty;
     bool moreTypes = true;
     for (int i = 0; moreTypes; artefactString = ArtefactFormatAttribute.GetString(artefact, i, out moreTypes))
         if (artefactString.Length > 0)
             sb.Append('\n').Append(' ', i * 2).Append(artefactString);
     return sb.ToString();
 }
Example #16
0
    // Use this for initialization
    void Start()
    {
        game = SharedInfo.getCurrGame();

        artefactId            = game.getCollectionStatus().getNextToCollect();
        nextArtefactToCollect = game.getCollection().getArtefactById(artefactId);

        GameObject.Find("CluePanel").GetComponentsInChildren <Text>()[0].text = getTitleFromNumber(nextArtefactToCollect.getId() + 1);
        GameObject.Find("CluePanel").GetComponentsInChildren <Text>()[1].text = nextArtefactToCollect.getClue();
    }
Example #17
0
 private void Awake()
 {
     _currentBullet = 0;
     _timer         = 0;
     _artefact      = GetComponent <Artefact>();
     _bullets       = new GameObject[_countBullet];
     for (int i = 0; i < _countBullet; i++)
     {
         _bullets[i] = GameObject.Instantiate(_bullet, transform);
     }
 }
Example #18
0
 public void updateGame(Collection collection, CollectionStatus collectionStatus, Artefact currentArtefact, bool artefactJustCollected)
 {
     if(collection != null)
         this.collection = collection;
     if(collectionStatus!=null)
         this.collectionStatus = collectionStatus;
     if(currentArtefact!=null)
         this.currentArtefact = currentArtefact;
     if(artefactJustCollected!=null)
         this.artefactJustCollected = artefactJustCollected;
 }
Example #19
0
    public Attack(IA ia) : base(ia)
    {
        aggressivity = (Aggressivity)ia.desires [typeof(Aggressivity)];
        cowardice    = (Cowardice)ia.desires [typeof(Cowardice)];
        art          = ia.player.team.teamSlot.artefact;

        weapon        = ia.GetComponent <StdIAWeapon> ();
        weapon.barrel = ia.barrel;

        timer = 0f;
    }
Example #20
0
        public ArtefactDto GetById(int artefactId)
        {
            Artefact artefact = Db.Artefacts.Find(artefactId);

            if (artefact == null)
            {
                NotFoundException();
            }

            return(Mapper.Map <ArtefactDto>(artefact));
        }
Example #21
0
        // For the correct operation of all find methods below.
        // We must overload the artifact comparison operator.

        // Shit happening, when we finding artefact.
        // I don't know why, but artefact in our inventory changing
        // every time, when we pass another argument
        public int findArtefactSlot(Artefact artefact)
        {
            for (int i = 0; i < this.capacity_artefacts; i++)
            {
                if (inventoryArtefacts[i].Equals(artefact))
                {
                    return(i);
                }
            }
            return(-1);
        }
Example #22
0
 public void SetArtefacts(Artefact artefact)
 {
     if (artefact.IsActivePower)
     {
         activeArtefact = artefact;
     }
     else
     {
         passiveArtefact = artefact;
         passiveArtefact.UseArtefact();
     }
 }
 public void SetTarget()
 {
     if (target == null || target.transporter != null)
     {
         target = null;
         Artefact art = FindAvailableArtefact();
         if (art != null)
         {
             target = art;
         }
     }
 }
Example #24
0
        //method that uses artefact and returns true, when artefact is in inventory, otherwise doesn't use and return false
        private bool TryUseArtefact(Artefact artefact, Wizard origin, Wizard target)
        {
            var usedItemIndex = origin._inventory.FindIndex(targetArtefact => targetArtefact.ToString() == artefact.ToString());

            if (usedItemIndex != -1)
            {
                origin.UseArtefact(origin._inventory[usedItemIndex], target);
                return(true);
            }

            return(false);
        }
Example #25
0
    void Update()

    {
        // Only is the panel is hidden
        if (!isPanelUp())
        {
            Artefact currentArtefact = game.getCurrentArtefact();
            //Debug.Log ("artefact" + currentArtefact.getName());
            if (currentArtefact != null)
            {
                Transform artTransform = GameObject.Find(currentArtefact.getName()).transform;
                if (Input.touchCount == 1)
                {
                    var touch = Input.GetTouch(0);

                    switch (touch.phase)
                    {
                    case TouchPhase.Moved:

                        artTransform.Translate(0, touch.deltaPosition.y * 0.3f, 0);
                        artTransform.Rotate(0, -touch.deltaPosition.x * 0.3f, 0);

                        if (!isVector3DInsideBottomWindow(artTransform.position))
                        {
                            artTransform.Translate(0, -touch.deltaPosition.y * 0.3f, 0);
                            artTransform.Rotate(0, +touch.deltaPosition.x * 0.3f, 0);
                        }
                        break;
                    }
                }
                else if (Input.touchCount == 2)
                {
                    Touch touchZero = Input.GetTouch(0);
                    Touch touchOne  = Input.GetTouch(1);

                    Vector2 touchZeroPrevPos = touchZero.position - touchZero.deltaPosition;
                    Vector2 touchOnePrevPos  = touchOne.position - touchOne.deltaPosition;

                    float prevTouchDeltaMag = (touchZeroPrevPos - touchOnePrevPos).magnitude;
                    float touchDeltaMag     = (touchZero.position - touchOne.position).magnitude;

                    float deltaMagnitudeDiff = prevTouchDeltaMag - touchDeltaMag;

                    GetComponent <Camera> ().fieldOfView += deltaMagnitudeDiff * perspectiveZoomSpeed;
                    GetComponent <Camera> ().fieldOfView  = Mathf.Clamp(GetComponent <Camera> ().fieldOfView, 20.1f, 120.9f);
                }
            }
            else
            {
                Debug.Log("TODO selectedArtefact is null");
            }
        }
    }
        public ArtefactDto Update(ArtefactDto dto)
        {
            if (string.IsNullOrEmpty(dto.Name))
            {
                throw new ArgumentNullException("Name");
            }

            Artefact artefact = Db.Artefacts.FirstOrDefault(m => m.Id == dto.Id);

            if (artefact == null)
            {
                NotFoundException();
            }

            artefact.Name               = dto.Name;
            artefact.Description        = dto.Description;
            artefact.Image              = dto.Image;
            artefact.ImageFileType      = dto.ImageFileType;
            artefact.AdditionalComments = dto.AdditionalComments;
            artefact.AcquisitionDate    = dto.AcquisitionDate;
            artefact.Measurement_Height = dto.Measurement_Height;
            artefact.Measurement_Length = dto.Measurement_Length;
            artefact.Measurement_Width  = dto.Measurement_Width;
            artefact.ArtefactStatus     = (int)dto.ArtefactStatus;
            artefact.IsDeleted          = dto.IsDeleted;
            artefact.ModifiedDate       = DateTime.UtcNow;
            artefact.XBound             = dto.XBound;
            artefact.YBound             = dto.YBound;

            //Process zone
            if (dto.Zone != null && dto.Zone.Id > 0)
            {
                artefact.Zone = Db.Zones.Find(dto.Zone.Id);
            }
            else
            {
                artefact.Zone = null;
            }

            //Process Category
            if (dto.ArtefactCategory != null && dto.ArtefactCategory.Id > 0)
            {
                artefact.ArtefactCategory = Db.ArtefactCategories.Find(dto.ArtefactCategory.Id);
            }
            else
            {
                artefact.ArtefactCategory = null;
            }

            Db.SaveChanges();

            return(Mapper.Map <ArtefactDto>(artefact));
        }
Example #27
0
 protected TestBase(ICryptographyFactory cryptographyFactory = null)
 {
     _network        = new Network(cryptographyFactory ?? new SimpleCryptographyFactory());
     MyAccount       = _network.CreateRootAccount("MyAccount", 1);
     OtherAccount    = _network.CreateRootAccount("OtherAccount", 2);
     ThirdAccount    = _network.CreateRootAccount("ThirdAccount", 3);
     MyActor         = MyAccount.GetActor(_network, _transactionFactory);
     OtherActor      = OtherAccount.GetActor(_network, _transactionFactory);
     ThirdActor      = ThirdAccount.GetActor(_network, _transactionFactory);
     Artefact        = new Artefact((ArtefactId)"255:1", "SomeArtefact", (AgentId)"255");
     AnotherArtefact = new Artefact((ArtefactId)"255:2", "AnotherArtefact", (AgentId)"255");
 }
Example #28
0
        public void GetArtefact(Artefact artefact)
        {
            int emptySlot = findEmptySlot(emptyArtefactsPlaces);

            if (emptySlot == -1)
            {
                throw new Exception(rm.GetString("ArtefactsLimit"));
            }
            else
            {
                inventoryArtefacts[emptySlot]   = artefact;
                emptyArtefactsPlaces[emptySlot] = false;
            }
        }
Example #29
0
        public ArtefactDto Create(ArtefactDto dto)
        {
            if (string.IsNullOrEmpty(dto.Name))
            {
                throw new ArgumentNullException("Name");
            }

            Artefact artefact = new Artefact
            {
                Name               = dto.Name,
                Description        = dto.Description,
                Image              = dto.Image,
                ImageFileType      = dto.ImageFileType,
                AdditionalComments = dto.AdditionalComments,
                AcquisitionDate    = dto.AcquisitionDate,
                Radius_Of_Effect   = dto.Radius_Of_Effect,
                Coord_X            = dto.Coord_X,
                Coord_Y            = dto.Coord_Y,
                Activation         = dto.Activation,
                ArtefactStatus     = (int)dto.ArtefactStatus,
                CreatedDate        = DateTime.UtcNow,
                ModifiedDate       = DateTime.UtcNow,
                IsDeleted          = false
            };

            //Add Zone
            if (dto.Zone != null && dto.Zone.Id > 0)
            {
                artefact.Zone = Db.Zones.Find(dto.Zone.Id);
            }

            //Add category
            if (dto.ArtefactCategory != null && dto.ArtefactCategory.Id > 0)
            {
                artefact.ArtefactCategory = Db.ArtefactCategories.Find(dto.ArtefactCategory.Id);
            }

            //Add Beacon
            if (dto.Beacon != null && dto.Beacon.Id > 0)
            {
                artefact.Beacon = Db.Beacons.Find(dto.Beacon.Id);
            }

            Db.Artefacts.Add(artefact);

            Db.SaveChanges();

            return(Mapper.Map <ArtefactDto>(artefact));
        }
Example #30
0
    public override bool Equals(System.Object obj)
    {
        if (obj == null)
        {
            return(false);
        }

        Artefact artefact = obj as Artefact;

        if ((System.Object)artefact == null)
        {
            return(false);
        }
        return((getName() == artefact.getName()) && (getId() == artefact.getId()));
    }
Example #31
0
 void InitializeArtefacts()
 {
     foreach (TeamSlot ts in teamSlots)
     {
         GameObject artefact = Instantiate(ts.artefactPrefab);
         artefact.transform.position = ts.artefactSpawn.transform.position;
         Artefact art = artefact.GetComponent <Artefact> ();
         art.team    = ts.team;
         art.spawn   = ts.artefactSpawn.transform;
         ts.artefact = art;
         ArtefactReceptor receptor = ts.receptor.GetComponent <ArtefactReceptor> ();
         receptor.team = ts.team;
         artefacts.Add(art);
     }
 }
Example #32
0
        public void DropArtefact(Artefact artefact)
        {
            int slot = findArtefactSlot(artefact);

            if (slot != -1)
            {
                emptyArtefactsPlaces[slot] = true;
                inventoryArtefacts[slot]   = null;
            }

            else
            {
                throw new Exception("You don't have this artefact.");
            }
        }
Example #33
0
    void Awake()
    {
        string filePath = Application.persistentDataPath + @"\" + narrativeFileName;

        Debug.Log(filePath);
        narrative = Narrative.Load(filePath);

        Station  item = new Station();
        Artefact art  = new Artefact();

        art.Name = "ART";

        item.Name = "station";
        item.Artefacts.Add(art);
        narrative.StationCollection.Add(item);
    }
Example #34
0
        public void WhenPeerEndorceArtefactWithWrongOwner_PeerLoosesTrust()
        {
            Interconnect(MyActor, OtherActor, ThirdActor);
            var artefact    = ThirdActor.CreateArtefact(Artefact.Name);
            var trustBefore = MyAccount.GetTrust(OtherId);

            OtherAccount.ForgetArtefact(artefact.Id);

            var fakeArtefact = new Artefact(artefact, OtherId);

            OtherActor.EndorceArtefact(fakeArtefact);

            var expectedTrust = trustBefore.Decrease(EndorceCounterfeitArtefactDistrustFactor);

            Assert.Equal(expectedTrust, MyAccount.GetTrust(OtherId));
        }
Example #35
0
        public bool Delete(int artefactId)
        {
            Artefact artefact = Db.Artefacts.FirstOrDefault(m => m.Id == artefactId);

            if (artefact == null)
            {
                NotFoundException();
            }

            artefact.IsDeleted    = true;
            artefact.ModifiedDate = DateTime.UtcNow;

            Db.SaveChanges();

            return(true);
        }
Example #36
0
 public void TrackMotion(Actor actor, Motion motion)
 {
     if (sequence != null)
     {
         if (sequence[sequenceProgress].actor == actor && sequence[sequenceProgress].motion == motion)
         {
             currentArtefact.Highlight();
             sequenceProgress++;
         }
         if (sequenceProgress == sequence.Count)
         {
             currentArtefact.Solved();
             currentArtefact = null;
             sequence        = null;
         }
     }
 }
Example #37
0
 public bool isCollected(Artefact artefact)
 {
     bool isCollected;
     collectionStatus.TryGetValue (artefact.getId (), out isCollected);
     return isCollected;
 }
Example #38
0
 public void setAsCollected(Artefact artefact)
 {
     collectionStatus.Add(artefact.getId(), true);
 }
Example #39
0
 /// <summary>
 /// Update the specified artefact.
 /// </summary>
 /// <param name="artefact">Artefact.</param>
 /// <remarks>IRepository implementation</remarks>
 public void Update(Artefact artefact)
 {
     ITransaction transaction = null;
     try
     {
         if (Session.Transaction == null || !Session.Transaction.IsActive)
             transaction = Session.BeginTransaction();
     //				int id = artefact.Id.Value;
     //				if (_artefactCache.ContainsKey(id))
     //					_artefactCache[id].CopyMembersFrom(artefact);
     //				else
     //					_artefactCache[id] = artefact;
     //				Session.Update(artefact, artefact.Id);						// TODO: Think about this: if Session.Update fails _artefactCache will be invalid??
         Session.Merge(artefact);						// TODO: Think about this: if Session.Update fails _artefactCache will be invalid??
         if (transaction != null)
             transaction.Commit();
     }
     catch (Exception ex)
     {
         if (transaction != null)
             transaction.Rollback();
         throw Error(ex, artefact);
     }
     finally
     {
         if (transaction != null)
             transaction.Dispose();
     }
 }
Example #40
0
        public static void Main(string[] args)
        {
            bool exitServiceHost = false;

            //			Console.ReadKey();

            //			ISession sesh = NHibernate_Helper.Session;

            //			Execute("../../../ArtefactServiceHost/bin/Debug/ArtefactServiceHost.exe");
            Thread serviceHostThread = new Thread(() =>
            {
                using (ServiceHost sh = ArtefactServiceHost.ArtefactServiceHost.BuildServiceHost())
                {
                    try
                    {
                        sh.Open();		// need a brief thread.sleep before writing state string??

                        Console.WriteLine("Service: " + sh.Description.ServiceType.FullName + " (" +
                            sh.Description.Namespace + sh.Description.Name + ")"
                        );
                        foreach (ServiceEndpoint endpoint in sh.Description.Endpoints)
                        {
            //							foreach (OperationDescription od in endpoint.Contract.Operations)
            //							{
            //								DataContractSerializerOperationBehavior contractBehaviour =
            //									od.Behaviors.Find<DataContractSerializerOperationBehavior>();
            //								if (contractBehaviour == null)
            //									contractBehaviour = new DataContractSerializerOperationBehavior(od);
            //								contractBehaviour.
            //							}
                            Console.WriteLine(endpoint.ToString(true));
                        }
                        Console.WriteLine();

                        while (!exitServiceHost)
                            Thread.Sleep(255);
                    }
                    catch (Exception ex)
                    {
                        Console.Error.WriteLine("\nServiceHost Exception (State={0}):\n{1}\n", sh.State.ToString(), ex.ToString());
                    }
                    finally
                    {
                        if (sh.State != CommunicationState.Closed && sh.State != CommunicationState.Closing)
                            sh.Close();
                    }
                }
            });

            try
            {
                Console.ReadKey();

                // Start service host thread and pause for a few seconds to ensure it has started
                serviceHostThread.Start();
                Thread.Sleep(2880);

                IArtefactRepository proxy = new ChannelFactory<IArtefactRepository>(
                    new NetTcpBinding(SecurityMode.None),
                    "net.tcp://localhost:3333/ArtefactRepository")
                    .CreateChannel();
                Console.WriteLine("Client: proxy=\"{0}\"\n", proxy.ToString());

                Artefact testArtefact = new Artefact();
                Console.WriteLine("testArtefact: {0}", testArtefact.ToString());
                testArtefact = (Artefact)proxy.AddArtefact(testArtefact);
                Console.WriteLine("proxy.AddArtefact(testArtefact) returned Id={0}", testArtefact.Id == null ? "(null)" : testArtefact.Id.ToString());

                Console.WriteLine();
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine("\nIArtefactRepository Exception\n" + ex.ToString() + "\n"); 		// + (proxy == null ? "" : proxy.State.ToString()) + "):
            }
            finally
            {
                Console.WriteLine("Stopping service host thread...");
                exitServiceHost = true;
                if (serviceHostThread.Join(2880))
                    Console.WriteLine("Stopped cleanly\n");
                else
                    Console.WriteLine("Thread.Join() unsuccessful\n");
            }
        }
Example #41
0
 /// <summary>
 /// Gets the identifier.
 /// </summary>
 /// <returns>The identifier.</returns>
 /// <param name="artefact">Artefact.</param>
 /// <remarks>IRepository implementation</remarks>
 public int GetId(Artefact artefact)
 {
     try
     {
         return artefact.IsTransient ? (artefact.Id = (int)Session.GetIdentifier(artefact)).Value : artefact.Id.Value;
     }
     catch (Exception ex)
     {
         throw Error(ex, artefact);
     }
 }
Example #42
0
 public void setCurrentArtefact(Artefact currentArtefact)
 {
     this.currentArtefact = currentArtefact;
 }
        private void OnTrackingFound()
        {
            bool isVisible = false;
            Collider artefactCollider = new Collider();
            Renderer artefactRenderer = new Renderer(), artefactRendererExtra = new Renderer(), questionMarkRenderer = new Renderer();
            Artefact currArtefact = new Artefact ();

            Renderer[] rendererComponents = GetComponentsInChildren<Renderer>(true);
            Collider[] colliderComponents = GetComponentsInChildren<Collider>(true);

            // Each time a new artefact is found, clean any old pup up messages
            GameObject.Find("CameraFinderSceneManager").GetComponent<PopUpManager>().setShowPopUp(false);

            // Enable rendering:
            foreach (Renderer component in rendererComponents)
            {
                string componentName = component.gameObject.name.Replace("Texture","");

                if(componentName == "Cippus0" || componentName == "Cippus1"){
                    if(componentName == "Cippus0"){
                        artefactRendererExtra = component;
                    }
                    componentName = "Cippus";
                }

                currArtefact = game.getCollection().getArtefactByName(componentName);
                //Debug.Log("Renderer: " + componentName);

                if(componentName == "FindOtherFirst")
                    questionMarkRenderer = component;

                else if(currArtefact != null)
                    artefactRenderer = component;
            }

            // Enable colliders:
            foreach (Collider component in colliderComponents)
            {
                currArtefact = game.getCollection().getArtefactByName(component.name);
                //Debug.Log("Collider: " + component.name);

                if(currArtefact != null){
                    artefactCollider = component;
                }
            }

            // Show the artefact
            if (currArtefact != null && currArtefact.getId() <= game.getCollectionStatus().getNextToCollect()) {
                // Only if the previous message has already been dismissed
                if(GameObject.Find ("InfoPanel-CameraFinder") == null){
                    // Only if first artefact and not already collrcted
                    // If you dont want to show anymore after the OK button was pressed add:
                    // && !SharedInfo.getSceneStatus().isVisited("ARartefact");
                    if(currArtefact.getId() == 0 && !game.collectionStatus.isCollected(currArtefact)  && !SharedInfo.getSceneStatus().isVisited("ARartefact")){
                        // Retrive unactive panel
                        Component[] infoPanels = GameObject.Find("InfoPanels").GetComponentsInChildren( typeof(Transform), true );
                        foreach(Component temp in infoPanels){
                            if (temp.name == "InfoPanel-ARartefact"){
                                temp.gameObject.SetActive(true);
                            }
                        }
                        GameObject.Find("InfoPanel-ARartefact").GetComponent<SceneStatusManager>().setShowPopUp(true);
                        // OR
                        //SharedInfo.getSceneStatus().setVisited ("ARartefact");
                        //GameObject.Find("InfoPanel-ARartefact").GetComponent<SceneStatusManager>().UpdateOnce();
                    }

                }
                questionMarkRenderer.enabled = false;
                artefactCollider.enabled = true;
                artefactRenderer.enabled = true;
                if(currArtefact.getName() == "Cippus")
                    artefactRendererExtra.enabled = true;

            } else {

                artefactCollider.enabled = false;
                artefactCollider.enabled = false;
                questionMarkRenderer.enabled = true;

            }

            //Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " found");
        }
        /// <summary>
        /// Gets the artefact string.
        /// </summary>
        /// <returns>
        /// The artefact string.
        /// </returns>
        /// <param name='artefact'>
        /// Artefact.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// Is thrown when an argument passed to a method is invalid because it is <see langword="null" /> .
        /// </exception>
        public string GetArtefactString(Artefact artefact)
        {
            if (artefact == null)
                throw new ArgumentNullException("artefact");

            if (string.IsNullOrEmpty(Format))
                return string.Empty;

            Type T = artefact.GetType();
            //			StringBuilder sb = new StringBuilder(ArtefactFormat, 256);
            string sb = Format;
            int i, i2 = 0;

            string memberName;
            MemberInfo mi;
            object member;
            string memberString;
            BindingFlags bf = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance |
                BindingFlags.FlattenHierarchy | BindingFlags.GetField | BindingFlags.GetProperty;
            i = sb.IndexOf('{');
            while (i >= 0 && i < sb.Length - 1)
            {
                i = sb.IndexOf('{', i);
                if (i >= 0)
                {
                    i2 = sb.IndexOf('}', i + 1);
                    if (i2 >= 0)
                    {
                        memberName = sb.Substring(i + 1, i2 - i - 1);
                        mi = T.GetMember(memberName)[0];
                        member = T.InvokeMember(memberName, bf, null, artefact, new object[] {});
                        sb = sb.Remove(i, i2 - i + 1);
                        memberString = member == null ? "(null)" : member.ToString();
                        sb = sb.Insert(i, memberString);
                        i += memberString.Length;
                    }
                    else
                        break;
                }
                else
                    break;
            }

            return sb.ToString();
        }
Example #45
0
 protected virtual void NotifyCreate(Artefact artefact)
 {
     foreach (IObserver<Artefact> observer in _observers)
         observer.OnNext(artefact);
 }
Example #46
0
 /// <summary>
 /// Copies the members from.
 /// </summary>
 /// <param name="source">Source.</param>
 public override void CopyMembersFrom(Artefact source)
 {
     base.CopyMembersFrom(source);
     Drive srcDrive = (Drive)source;
     Disk = srcDrive.Disk;
     Partition = srcDrive.Partition;
     Label = srcDrive.Label;
     Format = srcDrive.Format;
     Type = srcDrive.Type;
     Size = srcDrive.Size;
     FreeSpace = srcDrive.FreeSpace;
     AvailableFreeSpace = srcDrive.AvailableFreeSpace;
 }
Example #47
0
        /// <summary>
        /// Gets the identifier.
        /// </summary>
        /// <returns>The identifier.</returns>
        /// <param name="artefact">Artefact.</param>
        /// <remarks>IRepository implementation</remarks>
        public int GetId(Artefact artefact)
        {
            Console.WriteLine("GetId(#{1}:{0})", artefact.GetType().FullName,
            artefact.Id.HasValue ? artefact.Id.ToString() : "(null)",
            OperationContext.Current == null ? "(OpCtx=null)" :
                                OperationContext.Current.ToString());
            //				.RequestContext == null ? "(RqCtx=null)" :
            //				OperationContext.Current.RequestContext.RequestMessage == null ? "(RqMsg=null)" :
            //					OperationContext.Current.RequestContext.RequestMessage.ToString());

            try
            {
                return artefact.IsTransient ? (artefact.Id = (int)Session.GetIdentifier(artefact)).Value : artefact.Id.Value;
            }
            catch (Exception ex)
            {
                throw Error(ex, artefact);
            }
        }
Example #48
0
        /// <summary>
        /// Remove the specified artefact.
        /// </summary>
        /// <param name="artefact">Artefact.</param>
        /// <remarks>IRepository implementation</remarks>
        public void Remove(Artefact artefact)
        {
            Console.WriteLine("Remove(#{1}:{0})",  artefact.GetType().FullName,
            artefact.Id.HasValue ? artefact.Id.ToString() : "(null)",
            OperationContext.Current == null ? "(OpCtx=null)" :
                                OperationContext.Current.ToString());
            //				.RequestContext == null ? "(RqCtx=null)" :
            //				OperationContext.Current.RequestContext.RequestMessage == null ? "(RqMsg=null)" :
            //					OperationContext.Current.RequestContext.RequestMessage.ToString());

            ITransaction transaction = null;
            //			int id = -1;
            try
            {
                if (!artefact.IsTransient)
                {
                    int id = artefact.Id.Value;
                    if (Session.Transaction == null || !Session.Transaction.IsActive)
                        transaction = Session.BeginTransaction();
                    Session.Delete(artefact.Id);
                    if (_artefactCache.ContainsKey(id))
                        _artefactCache.Remove(id);
                    if (transaction != null)
                        transaction.Commit();
                }
            }
            catch (Exception ex)
            {
                if (transaction != null)
                    transaction.Rollback();
            //				else
            //					Session.Save(artefact, id);
                throw Error(ex, artefact);
            }
            finally
            {
                if (transaction != null)
                    transaction.Dispose();
            }
        }
Example #49
0
 public void resetGame()
 {
     collectionStatus = new CollectionStatus(collection.getTotal());
     currentArtefact = null;
     artefactJustCollected = false;
 }
Example #50
0
        /// <summary>
        /// Update the specified artefact.
        /// </summary>
        /// <param name="artefact">Artefact.</param>
        /// <remarks>IRepository implementation</remarks>
        public void Update(Artefact artefact)
        {
            Console.WriteLine("Update(#{1}:{0})",  artefact.GetType().FullName,
            artefact.Id.HasValue ? artefact.Id.ToString() : "(null)",
            OperationContext.Current == null ? "(OpCtx=null)" :
                                OperationContext.Current.ToString());
            //				.RequestContext == null ? "(RqCtx=null)" :
            //				OperationContext.Current.RequestContext.RequestMessage == null ? "(RqMsg=null)" :
            //					OperationContext.Current.RequestContext.RequestMessage.ToString());

            ITransaction transaction = null;
            try
            {
                if (Session.Transaction == null || !Session.Transaction.IsActive)
                    transaction = Session.BeginTransaction();
            //				int id = artefact.Id.Value;
            //				if (_artefactCache.ContainsKey(id))
            //					_artefactCache[id].CopyMembersFrom(artefact);
            //				else
            //					_artefactCache[id] = artefact;
            //				Session.Update(artefact, artefact.Id);						// TODO: Think about this: if Session.Update fails _artefactCache will be invalid??
                Session.Merge(artefact);						// TODO: Think about this: if Session.Update fails _artefactCache will be invalid??
                if (transaction != null)
                    transaction.Commit();
            }
            catch (Exception ex)
            {
                if (transaction != null)
                    transaction.Rollback();
                throw Error(ex, artefact);
            }
            finally
            {
                if (transaction != null)
                    transaction.Dispose();
            }
        }
Example #51
0
 /// <summary>
 /// Remove the specified artefact.
 /// </summary>
 /// <param name="artefact">Artefact.</param>
 /// <remarks>IRepository implementation</remarks>
 public void Remove(Artefact artefact)
 {
     ITransaction transaction = null;
     //			int id = -1;
     try
     {
         if (!artefact.IsTransient)
         {
             int id = artefact.Id.Value;
             if (Session.Transaction == null || !Session.Transaction.IsActive)
                 transaction = Session.BeginTransaction();
             Session.Delete(artefact.Id);
             if (_artefactCache.ContainsKey(id))
                 _artefactCache.Remove(id);
             if (transaction != null)
                 transaction.Commit();
         }
     }
     catch (Exception ex)
     {
         if (transaction != null)
             transaction.Rollback();
     //				else
     //					Session.Save(artefact, id);
         throw Error(ex, artefact);
     }
     finally
     {
         if (transaction != null)
             transaction.Dispose();
     }
 }
Example #52
0
 /// <summary>
 /// Add the specified artefact.
 /// </summary>
 /// <param name="artefact">Artefact.</param>
 /// <remarks>IRepository implementation</remarks>
 public int Add(Artefact artefact)
 {
     ITransaction transaction = null;
     int id = -1;
     try
     {
         if (Session.Transaction == null || !Session.Transaction.IsActive)
             transaction = Session.BeginTransaction();
         artefact.Id = id = (int)Session.Save(artefact);
         _artefactCache.Add(id, artefact);
         if (transaction != null)
             transaction.Commit();
         return id;
     }
     catch (Exception ex)
     {
         if (transaction != null)
             transaction.Rollback();
         if (!artefact.IsTransient)
         {
             if (transaction == null)
                 Session.Delete(artefact);
             if (_artefactCache.ContainsKey(id))
                 _artefactCache.Remove(id);
         }
         throw Error(ex, artefact);
     }
     finally
     {
         if (transaction != null)
             transaction.Dispose();
     }
 }