예제 #1
0
 void Awake()
 {
     sr    = this.GetComponent <SpriteRenderer>();
     pac   = this.GetComponent <PersonAnimationController> ();
     myInv = this.GetComponent <Inventory> ();
     ac    = this.GetComponentInChildren <ArtemAnimationController> ();
 }
    Position firstPoint = null;//第一个点的位置 自动移动进度条到该点

    /// <summary>
    /// 显示某个标签的历史数据
    /// </summary>
    /// <param name="code"></param>
    public void ShowHistoryData()
    {
        if (isLoadDataSuccessed)
        {
            return;
        }
        //LocationManager.Instance.ClearHistoryPaths();
        //string code = "0002";

        List <HistoryPersonUIItem> historyPersonUIItems = personsGrid.GetComponentsInChildren <HistoryPersonUIItem>().ToList();

        DateTime end   = GetEndTime();
        DateTime start = GetStartTime();
        List <List <Position> > psList = new List <List <Position> >();

        personnel_Points = new Dictionary <Personnel, List <Position> >();
        //List<Position> ps = new List<Position>();
        List <LocationHistoryPath_M> paths = new List <LocationHistoryPath_M>();

        progressbarLoadValue = 0;

        List <int> topoNodeIds = RoomFactory.Instance.GetCurrentDepNodeChildNodeIds(SceneEvents.DepNode);

        Loom.StartSingleThread(() =>
        {
            firstPoint = null;
            foreach (Personnel p in currentPersonnels)
            {
                List <Position> ps = GetHistoryData(p.Id, topoNodeIds, start, end, 1440f);
                psList.Add(ps);
                if (personnel_Points.ContainsKey(p))
                {
                    personnel_Points[p] = ps;
                }
                else
                {
                    personnel_Points.Add(p, ps);
                }
                if (ps != null && ps.Count > 0)
                {
                    Position fps = ps[0];
                    if (firstPoint == null)
                    {
                        firstPoint = fps;
                    }
                    else
                    {
                        if (fps.Time < firstPoint.Time)
                        {
                            firstPoint = fps;
                        }
                    }
                }
            }
            Debug.Log("StartSingleThread1");
            Loom.DispatchToMainThread(() =>
            {
                ProgressbarLoad.Instance.Show(1);
                ProgressbarLoad.Instance.Hide();
                int k = 0;
                foreach (Personnel p in personnel_Points.Keys)
                {
                    List <Position> ps = personnel_Points[p];
                    Debug.LogError("点数:" + ps.Count);
                    if (ps.Count < 2)
                    {
                        continue;
                    }
                    var posInfoList = new PositionInfoList();
                    for (int i = 0; i < ps.Count; i++)
                    {
                        var posInfo = new PositionInfo(ps[i], start);
                        posInfoList.Add(posInfo);
                    }

                    Color colorT             = colors[k % colors.Count];
                    HistoryPersonUIItem item = historyPersonUIItems.Find((i) => i.personnel.Id == p.Id);
                    if (item != null)
                    {
                        colorT = item.color;
                    }

                    PathInfo pathInfo   = new PathInfo();
                    pathInfo.personnelT = p;
                    pathInfo.color      = colorT;
                    pathInfo.posList    = posInfoList;
                    pathInfo.timeLength = timeLength;

                    LocationHistoryPath_M histoyObj = LocationHistoryManager.Instance.ShowLocationHistoryPath_M(pathInfo);
                    //histoyObj.InitData(timeLength, timelist);
                    HistoryManController historyManController = histoyObj.gameObject.AddComponent <HistoryManController>();
                    histoyObj.historyManController            = historyManController;
                    historyManController.Init(colorT, histoyObj);
                    PersonAnimationController personAnimationController = histoyObj.gameObject.GetComponent <PersonAnimationController>();
                    personAnimationController.DoMove();
                    Debug.Log("StartSingleThread2");
                    k++;
                }
            });

            //Debug.Log("StartSingleThread3");
            Loom.DispatchToMainThread(() =>
            {
                isLoadDataSuccessed = true;
                //timeStart = Time.time;
                timeSum = 0;
                Debug.Log("StartSingleThread3");
                if (firstPoint != null)
                {
                    DateTime t = LocationManager.GetTimestampToDateTime(firstPoint.Time);
                    Debug.Log(firstPoint.Time);
                    timeSum = t.Hour * 3600 + t.Minute * 60 + t.Second - slider.ValueMin * 3600;
                    Debug.Log(timeSum);
                }
            });
        });
    }
예제 #3
0
    /// <summary>
    /// 显示某个标签的历史数据
    /// </summary>
    /// <param name="code"></param>
    public void ShowHistoryData()
    {
        if (isLoadDataSuccessed)
        {
            return;
        }
        //LocationManager.Instance.ClearHistoryPaths();
        //string code = "0002";
        List <Vector3>  list        = new List <Vector3>();
        List <DateTime> timelist    = new List <DateTime>();
        var             posInfoList = new PositionInfoList();
        DateTime        end         = GetEndTime();
        DateTime        start       = GetStartTime();

        //List<Position> positions = new List<Position>();
        positions = new List <Position>();

        List <int> topoNodeIds = RoomFactory.Instance.GetCurrentDepNodeChildNodeIds(SceneEvents.DepNode);


        Loom.StartSingleThread(() =>
        {
            //ps = CommunicationObject.Instance.GetHistoryPositonsByTime(code, start, end);
            positions = GetHistoryData(personnel.Id, topoNodeIds, start, end);

            Loom.DispatchToMainThread(() =>
            {
                Debug.LogError("点数:" + positions.Count);
                if (positions.Count < 2)
                {
                    return;
                }

                for (int i = 0; i < positions.Count; i++)
                {
                    var p = new PositionInfo(positions[i], start);
                    posInfoList.Add(p);
                }

                PathInfo pathInfo   = new PathInfo();
                pathInfo.personnelT = personnel;
                pathInfo.color      = Color.green;
                pathInfo.posList    = posInfoList;
                pathInfo.timeLength = timeLength;

                LocationHistoryPath histoyObj             = LocationHistoryManager.Instance.ShowLocationHistoryPath(pathInfo, "HistoryPath0002");
                HistoryManController historyManController = histoyObj.gameObject.AddComponent <HistoryManController>();
                histoyObj.historyManController            = historyManController;
                historyManController.Init(Color.green, histoyObj);
                PersonAnimationController personAnimationController = histoyObj.gameObject.GetComponent <PersonAnimationController>();
                personAnimationController.DoMove();

                PathFindingManager.Instance.StartNavAgent(historyManController);

                isLoadDataSuccessed = true;
                timeStart           = Time.time;
                timeSum             = 0;
                //histoyObj.InitData(timeLength, timelist);
            });
        });
    }
예제 #4
0
    public void die()
    {
        //add corpse to some kind of dead person list?
        if (this != playerHealth)
        {
            NPCManager.me.npcsInWorld.Remove(this.gameObject);
            NPCManager.me.corpsesInWorld.Add(this.gameObject);
            NPCController npc = this.GetComponent <NPCController> ();
            NPCManager.me.npcControllers.Remove(npc);
            if (npc.myText == null)
            {
            }
            else
            {
                npc.myText.fadeOutText = true;
            }
            Destroy(npc.currentBehaviour);
            npc.enabled = false;
            //this.GetComponent<NPCController> ().enabled = false;
            this.GetComponent <PersonWeaponController> ().enabled = false;
            this.GetComponent <PathFollower> ().enabled           = false;
            this.GetComponent <CanWeDetectTarget> ().enabled      = false;
            //this.gameObject.GetComponent<Pathfinding> ().enabled = false;
            this.gameObject.GetComponent <NPCBehaviourDecider> ().enabled = false;
            this.GetComponent <NPCMemory> ().enabled = false;
            this.GetComponent <PersonMovementController> ().enabled = false;
            npc.detect.fov.viewMeshFilter.gameObject.SetActive(false);
            npc.detect.fov.enabled = false;
            this.gameObject.AddComponent <PlayerAction_DragCorpse> ();
            this.gameObject.layer = 27;
            this.gameObject.GetComponentInChildren <CircleCollider2D> ().gameObject.layer = 27;
            this.transform.parent = null;

            Container c = this.gameObject.AddComponent <Container> ();
            c.containerName    = "Corpse";
            c.itemsInContainer = new List <Item> ();
            Inventory i = this.gameObject.GetComponent <Inventory> ();
            foreach (Item it in i.inventoryItems)
            {
                c.addItemToContainer(it);
            }
            i.inventoryItems.Clear();

            if (npc.myHalo == null)
            {
            }
            else
            {
                Destroy(npc.myHalo);
            }
            // if (LoadingDataStore.me.loadingDone==true)
            // {
            LevelIncidentController.me.addIncident("Murder", this.transform.position);
            //  }
        }

        SpriteRenderer[] srs = this.gameObject.GetComponentsInChildren <SpriteRenderer> ();

        foreach (SpriteRenderer sr in srs)
        {
            sr.sortingOrder = sr.sortingOrder - 10;
        }



        this.GetComponent <Rigidbody2D> ().isKinematic     = false;
        this.GetComponent <Rigidbody2D> ().angularVelocity = 0.0f;
        this.GetComponent <Rigidbody2D> ().velocity        = new Vector2(0, 0);

        PersonAnimationController pac = this.GetComponent <PersonAnimationController> ();

        pac.animationsToPlay.Clear();
        pac.playing = null;
        pac.counter = 0;
        pac.playAnimation("Die", true);
        this.gameObject.GetComponent <SpriteRenderer> ().sortingOrder = 1;
        ArtemAnimationController ac = this.gameObject.GetComponentInChildren <ArtemAnimationController> ();

        ac.setFallen();

        this.gameObject.tag = "Dead/Knocked";

        this.gameObject.GetComponent <PersonColliderDecider> ().onDeath();
        this.enabled = false;
    }
예제 #5
0
    public void knockedOut()
    {
        if (npcB.myType == AIType.hostage)
        {
            return;
        }

        //knockedDownTimer -= Time.deltaTime;

        if (knockedDownTimer <= 0)
        {
            PersonAnimationController pac = this.GetComponent <PersonAnimationController> ();
            pac.playAnimation("Unarmed", true);
            knockedDownTimer    = 5.0f;
            knockedDown         = false;
            this.gameObject.tag = "NPC";

            //legs.SetActive (true);
            ac.enableBodyParts();
            head.SetActive(true);
            pmc.enabled = true;
            pwc.enabled = true;

            myCol.setSolid();
            this.gameObject.GetComponent <SpriteRenderer> ().sortingOrder = 5;
            this.GetComponent <SpriteRenderer> ().sprite = null;

            detect.fov.enabled = true;
            detect.fov.viewMeshFilter.gameObject.SetActive(true);
            //npcB.
            npcB.alarmed = true;
            myText.setText("Ughhh my head");
            this.gameObject.GetComponentInChildren <CircleCollider2D> ().enabled = true;
            //ArtemAnimationController ac = this.gameObject.GetComponentInChildren<ArtemAnimationController> ();
            ac.setUp();
            if (this.GetComponent <PlayerAction_HumanShield> () == true)
            {
                this.GetComponent <PlayerAction_HumanShield> ().enabled = true;
            }
            SpriteRenderer[] srs = this.gameObject.GetComponentsInChildren <SpriteRenderer> ();

            foreach (SpriteRenderer sr in srs)
            {
                sr.sortingOrder = sr.sortingOrder + 10;
            }
            Container c = this.GetComponent <Container> ();
            Inventory i = this.GetComponent <Inventory> ();
            foreach (Item item in c.itemsInContainer)
            {
                i.addItemToInventory(item);
            }
            c.itemsInContainer.Clear();
            Destroy(c);
            if (this.GetComponent <PlayerAction_SearchContainer> () == true)
            {
                Destroy(this.GetComponent <PlayerAction_SearchContainer> ());
            }

            if (this.GetComponent <PlayerAction_DragCorpse> () == true)
            {
                Destroy(this.GetComponent <PlayerAction_DragCorpse> ());
            }

            if (this.GetComponent <PlayerAction_DropBody> () == true)
            {
                Destroy(this.GetComponent <PlayerAction_DropBody> ());
            }
        }
    }
예제 #6
0
    public void knockOutNPC()
    {
        if (npcB.myType == AIType.hostage)
        {
            return;
        }
        ArtemAnimationController ac = this.gameObject.GetComponentInChildren <ArtemAnimationController> ();

        ac.setFallen();
        PersonAnimationController pac = this.GetComponent <PersonAnimationController> ();

        //pac.forceFinishCurrentAnim ();
        pac.animationsToPlay.Clear();
        pac.playing = null;
        pac.counter = 0;
        pac.playAnimation("Knock", true);
        knockedDown = true;
        this.gameObject.GetComponent <SpriteRenderer> ().sortingOrder = 1;
        this.gameObject.tag = "Dead/Knocked";
        //ac.disableBodyParts ();
        //legs = this.GetComponentInChildren<Legs> ().gameObject;
        //legs.SetActive (false);
        head = ac.getHead();         //this.GetComponentInChildren<HeadController> ().gameObject;
        //this.GetComponent<SpriteRenderer> ().sprite = ac.myAesthetic.knocked;
        this.GetComponent <Rigidbody2D> ().isKinematic     = true;
        this.GetComponent <Rigidbody2D> ().angularVelocity = 0.0f;
        this.GetComponent <Rigidbody2D> ().velocity        = new Vector2(0, 0);
        //head.SetActive (false);
        pmc.enabled = false;
        pwc.enabled = false;
        //this.GetComponent<Collider2D> ().isTrigger = true;
        myCol.setTrigger();
        this.gameObject.GetComponentInChildren <CircleCollider2D> ().enabled = false;

        detect.fov.enabled = false;
        detect.fov.viewMeshFilter.gameObject.SetActive(false);
        //this.gameObject.AddComponent<PlayerAction_TieUpHostage> ();
        if (this.GetComponent <PlayerAction_HumanShield> () == true)
        {
            this.GetComponent <PlayerAction_HumanShield> ().enabled = false;
        }
        SpriteRenderer[] srs = this.gameObject.GetComponentsInChildren <SpriteRenderer> ();

        foreach (SpriteRenderer sr in srs)
        {
            sr.sortingOrder = sr.sortingOrder - 10;
        }

        Container c = this.gameObject.AddComponent <Container> ();

        c.containerName    = "Unconscious Person";
        c.itemsInContainer = new List <Item> ();
        Inventory i = this.gameObject.GetComponent <Inventory> ();

        foreach (Item it in i.inventoryItems)
        {
            c.addItemToContainer(it);
        }
        i.inventoryItems.Clear();
        this.gameObject.AddComponent <PlayerAction_DragCorpse> ();
    }