Example #1
0
 public void registerClickArea(Rect linkedArea, InformationBase informationBase)
 {
     if (!clickAreas.ContainsKey(linkedArea))
     {
         clickAreas.Add(linkedArea, informationBase);
     }
 }
Example #2
0
    public PROPAGATION onMessage(string message, object data)
    {
//        Debug.Log("Click InformationWindow");
        if (message == "Click")
        {
            // Check if a link was clicked inside of an already shown informationWindow
            Vector2 clickPosScreen = Misc.getScreenPos((Vector3)data);
            foreach (KeyValuePair <Rect, InformationBase> clickArea in clickAreas)
            {
                if (Misc.isInside(clickPosScreen, clickArea.Key))
                {
                    scrollScreenToAndShowInformationFor(clickArea.Value);
                    return(PROPAGATION.STOP_IMMEDIATELY);
                }
            }

            InformationBase clickedInformationBase = InformationBase.GetInformationBaseAtPosition((Vector3)data);

            if (clickedInformationBase != null)
            {
                showInformation(clickedInformationBase);
                return(PROPAGATION.STOP_IMMEDIATELY);
            }
        }
        else if (message == "InformationWindow:hide")
        {
            hideInformation();
        }
        return(PROPAGATION.DEFAULT);
    }
    // Use this for initialization
    void Start()
    {
        var reader = new StreamReader(File.OpenRead(@"C:\test.dat"));

        Dictionary <string, List <InformationBase> > info_dictionary =
            new Dictionary <string, List <InformationBase> >();

        while (!reader.EndOfStream)
        {
            string[] character_line    = reader.ReadLine().Split('|');
            string   character_name    = character_line[0];
            string   characters_blocks = character_line[1];
            List <InformationBase> character_information = new List <InformationBase>();
            foreach (string information_data in characters_blocks.Split(';'))
            {
                string[]        block_data = information_data.Split(',');
                InformationBase info       = new InformationBase(block_data[0], block_data[1], block_data[2]);
                character_information.Add(info);
            }
            info_dictionary.Add(character_name, character_information);
        }

        foreach (GameObject character_game_object in GameObject.FindGameObjectsWithTag("Character"))
        {
            character_game_object.AddComponent <CharacterData>();
            CharacterData character      = character_game_object.GetComponent <CharacterData>();
            string        character_name = character_game_object.GetComponent <Character>().name;
            if (info_dictionary.ContainsKey(character_name))
            {
                character.infoOwned = info_dictionary[character_name];
            }
        }
    }
Example #4
0
    // Use this for initialization
    void Start()
    {
        var reader = new StreamReader(File.OpenRead(@"C:\test.dat"));

        Dictionary<string, List<InformationBase>> info_dictionary =
            new Dictionary<string, List<InformationBase>>();

        while (!reader.EndOfStream)
        {
            string[] character_line = reader.ReadLine().Split('|');
            string character_name = character_line[0];
            string characters_blocks = character_line[1];
            List<InformationBase> character_information = new List<InformationBase>();
            foreach (string information_data in characters_blocks.Split(';')){
                string[] block_data = information_data.Split (',');
                InformationBase info = new InformationBase(block_data[0],block_data[1],block_data[2]);
                character_information.Add(info);
            }
            info_dictionary.Add(character_name,character_information);
        }

        foreach(GameObject character_game_object in GameObject.FindGameObjectsWithTag("Character")){
            character_game_object.AddComponent<CharacterData>();
            CharacterData character = character_game_object.GetComponent<CharacterData>();
            string character_name = character_game_object.GetComponent<Character>().name;
            if (info_dictionary.ContainsKey(character_name))
            {
                character.infoOwned = info_dictionary[character_name];
            }
        }
    }
Example #5
0
 public void Detach(InformationBase info, InformationBase item)
 {
     if (info.Attachments.Any(x => x == item.ItemId) == false)
     {
         return;
     }
     info.Attachments.Remove(item.ItemId);
     info.IsModified = true;
 }
Example #6
0
 public void Attach(InformationBase info, InformationBase item)
 {
     if (info.Attachments.Contains(item.ItemId))
     {
         return;
     }
     info.Attachments.Add(item.ItemId);
     info.IsModified = true;
 }
Example #7
0
    public void showInformation(InformationBase info)
    {
        scrollPosition    = Vector2.zero;
        informationObject = info;
        information       = info.getInformation();
//		scrollToInformationBase(informationObject);
//		follow = informationObject.GetType() == typeof(InformationHuman);
        show = true;
    }
 public void UnTag(InformationBase info, Value value)
 {
     if (info.Values.Contains(value.ItemId) == false)
     {
         return;
     }
     info.Values.Remove(value.ItemId);
     info.IsModified = true;
 }
 public void Save(InformationBase item)
 {
     //Honor the control flags
     if (item.IsModified || item.IsNew)
     {
         item.IsModified = false;
         item.IsNew      = false;
         _elasticClient.Index(item, x => x.Type(item.GetType()));
     }
 }
 public void Tag(InformationBase info, Value value)
 {
     //Metadata label values are not allowed to be tagged
     if (info is Value || info is Label)
     {
         return;
     }
     if (info.Values.Contains(value.ItemId))
     {
         return;
     }
     info.Values.Add(value.ItemId);
     info.IsModified = true;
 }
        public List <Value> GetItemMetadataValues(InformationBase info)
        {
            var result = new List <Value>();

            foreach (var valueId in info.Values)
            {
                var value = MetadataValues.FirstOrDefault(x => x.ItemId == valueId);
                if (value == null)
                {
                    continue;
                }
                result.Add(value);
            }
            return(result);
        }
Example #12
0
    public static InformationBase GetInformationBaseAtPosition(Vector3 position, bool ignorePOI = false)
    {
        InformationBase clickedInformationBase = null;

        // Check for clicking to get information on actual informationBase-objects
        InformationBase[] informationBaseObjects = FindObjectsOfType <InformationBase> ();

        CircleTouch clickedCircleTouch = null;

        foreach (InformationBase informationBaseObject in informationBaseObjects)
        {
            if (!informationBaseObject.passive)
            {
                // Get click position (x,y) in a plane of the objects' Z position
                Plane   plane    = new Plane(Vector3.forward, new Vector3(0f, 0f, informationBaseObject.gameObject.transform.position.z));
                Vector2 clickPos = Game.instance.screenToWorldPosInPlane(position, plane);

                float thresholdSurroundingArea = 0.1f * 3f; // Click 0.1 (vehicle length) multiplied by three
                if (informationBaseObject.type == InformationBase.TYPE_POI)
                {
                    if (ignorePOI)
                    {
                        continue;
                    }
                    thresholdSurroundingArea = 0.07f; // Click area around POI is smaller
                }
                CircleTouch informationObjectTouch = new CircleTouch(informationBaseObject.transform.position, thresholdSurroundingArea);
                if (informationObjectTouch.isInside(clickPos))
                {
                    if (informationObjectTouch.isCloser(clickPos, clickedCircleTouch))
                    {
                        clickedCircleTouch = informationObjectTouch;
                        clickedCircleTouch.setDistance(clickPos);
                        clickedInformationBase = informationBaseObject;
                    }
                }
            }
        }

        return(clickedInformationBase);
    }
        public void Delete(InformationBase item)
        {
            //Honor the control flags
            if (item.IsDeleted == false)
            {
                return;
            }

            //First remove the item from other item's attachments
            var attachedTo = _elasticClient.Search <dynamic>(s => s
                                                             .Query(q => q
                                                                    .Term(t => t.Field("Attachments").Value(item.ItemId))));

            foreach (InformationBase detach in attachedTo.Documents)
            {
                _attachmentProcessor.Detach(detach, item);
                Save(detach);
            }
            //Second remove the item from the index
            _elasticClient.Delete <dynamic>(item.ItemId);
        }
Example #14
0
 private void scrollToInformationBase(InformationBase informationBase)
 {
     CameraHandler.MoveTo(informationBase.gameObject, 0.2f);
 }
Example #15
0
 private void scrollScreenToAndShowInformationFor(InformationBase informationBase)
 {
     hideInformation();
     showInformation(informationBase);
 }
Example #16
0
    public PROPAGATION onMessage(string message, object data)
    {
        if (message == "RClick")
        {
            Vector3 position = (Vector3)data;
            if (mouseDownPosition == Misc.VECTOR3_NULL)
            {
                // Right click when no object is active for rerouting
                InformationBase selectedObject = InformationBase.GetInformationBaseAtPosition(position);
                if (selectedObject != null)
                {
                    GameObject rerouteGameObject = selectedObject.gameObject;
                    IReroute   componentIReroute = rerouteGameObject.GetComponent <IReroute>();
                    if (componentIReroute.isRerouteOk())
                    {
                        mouseDownPosition      = position;
                        RerouteInfo.gameObject = rerouteGameObject;
                        RerouteInfo.iReroute   = componentIReroute;
                        RerouteInfo.isVehicle  = selectedObject.type == InformationBase.TYPE_VEHICLE;
                        RerouteInfo.iReroute.pauseMovement();
                        RerouteInfo.isReroute    = false;
                        RerouteInfo.originalPath = RerouteInfo.iReroute.getPath();
                        RerouteInfo.positionOriginalPathHalos();
                        Vector3 objectPosition = rerouteGameObject.transform.position;
                        haloObject.transform.localPosition = new Vector3(objectPosition.x, objectPosition.y, 0f);
                        haloObject.SetActive(true);
                        originalParentObj.SetActive(true);
                        rerouteParentObj.SetActive(false);
                        inactivateHaloObjects(reroutePathHalos);
                    }
                    else
                    {
                        // Re-routing not accepted, play sound
                        GenericSoundEffects.playRerouteUnavailable();
                    }
                }
            }
            else
            {
                if (RerouteInfo.isReroute && RerouteInfo.reroutePath.Count > 0)
                {
                    RerouteInfo.iReroute.setPath(RerouteInfo.reroutePath);
                }
                haloObject.SetActive(false);
                originalParentObj.SetActive(false);
                rerouteParentObj.SetActive(false);
                inactivateHaloObjects(originalPathHalos);
                inactivateHaloObjects(reroutePathHalos);
                RerouteInfo.iReroute.resumeMovement();

                RerouteInfo.gameObject = null;
                RerouteInfo.iReroute   = null;
                mouseDownPosition      = Misc.VECTOR3_NULL;
            }
        }
        else if (message == "RMove")
        {
            if (RerouteInfo.gameObject != null)
            {
                Vector3 mousePos        = (Vector3)data;
                Vector3 objectScreenPos = Game.instance.objectToScreenPos(RerouteInfo.gameObject);
                float   moveFromObject  = Misc.getDistance(mousePos, objectScreenPos);
                if (moveFromObject >= DISTANCE_FOR_REROUTE)
                {
// Get re-route pos object
                    Vector2 mousePosVector2 = Game.instance.screenToWorldPosInBasePlane(mousePos);
                    Pos     pos             = NodeIndex.getPosClosestTo(mousePosVector2, RerouteInfo.isVehicle);

                    int pathPoints   = RerouteInfo.originalPath.Count;
                    Pos addToPathPos = null;
                    Pos targetPos    = RerouteInfo.originalPath[RerouteInfo.originalPath.Count - 1];
                    if (targetPos.Id == -1L)
                    {
                        addToPathPos = targetPos;
                        targetPos    = RerouteInfo.originalPath[RerouteInfo.originalPath.Count - 2];
                        pathPoints--;
                    }

                    if (pathPoints > 2)
                    {
                        Pos startPos = RerouteInfo.originalPath[1];
                        RerouteInfo.reroutePath = Game.calculateCurrentPaths(startPos, targetPos, RerouteInfo.originalPath[0], pos, RerouteInfo.isVehicle, !RerouteInfo.isVehicle);

                        if (RerouteInfo.reroutePath.Count > 0)
                        {
                            RerouteInfo.reroutePath.Insert(0, Game.createTmpPos(RerouteInfo.gameObject.transform.position));
                            if (addToPathPos != null)
                            {
                                // Remove last path, if endPos is on this wayReference
                                if (!RerouteInfo.isVehicle && RerouteInfo.gameObject.GetComponent <HumanLogic>().endWay.hasNodes(RerouteInfo.reroutePath[RerouteInfo.reroutePath.Count - 2], RerouteInfo.reroutePath[RerouteInfo.reroutePath.Count - 1]))
                                {
                                    RerouteInfo.reroutePath.RemoveAt(RerouteInfo.reroutePath.Count - 1);
                                }

                                // Human should walk to end pos (tmp Pos object)
                                RerouteInfo.reroutePath.Add(addToPathPos);
                            }
//                        if (!RerouteInfo.isVehicle && isGoingFrontAndBackOnWay(RerouteInfo.originalPath)) {
//                            RerouteInfo.reroutePath.RemoveAt(1);
//                        }
                            RerouteInfo.isReroute = true;
                            RerouteInfo.positionReroutePathHalos();
                            rerouteParentObj.SetActive(true);
                            originalParentObj.SetActive(false);
                            inactivateHaloObjects(originalPathHalos);
                        }
                        else
                        {
                            RerouteInfo.isReroute = false;
                            originalParentObj.SetActive(true);
                            rerouteParentObj.SetActive(false);
                            inactivateHaloObjects(reroutePathHalos);
                        }
                    }
                }
            }
            else if (RerouteInfo.isReroute)
            {
                RerouteInfo.isReroute = false;
                originalParentObj.SetActive(true);
                rerouteParentObj.SetActive(false);
                inactivateHaloObjects(reroutePathHalos);
            }
//            Debug.Log(objectScreenPos + " - " + mousePos);

//            Vector3 objectPosition = Game.getCameraPosition(pos);
//            haloObject.transform.localPosition = new Vector3(objectPosition.x, objectPosition.y, 0f);
//            haloObject.SetActive(true);
        }
        else if (message == "Graphics:quality")
        {
            float quality = Game.instance.graphicsQuality;
            numberOfHalosInPath = Mathf.FloorToInt(NUMBER_HALOS_MIN + (quality * (NUMBER_HALOS_MAX - NUMBER_HALOS_MIN)));
//            activateHaloObjects(originalPathHalos);
//            activateHaloObjects(reroutePathHalos);
        }
        return(PROPAGATION.DEFAULT);
    }
Example #17
0
 public InformationLink(InformationBase obj)
 {
     this.name            = obj.name;
     this.informationBase = obj;
 }