Exemplo n.º 1
0
 void SetAnimationScript()
 {
     if (movingAnimationScript != "")
     {
         var acomp = birdformgo.GetComponent <Animator>();
         if (acomp != null)
         {
             acomp.applyRootMotion = false;
             var script = restingAnimationScript;
             if (BirdState == BirdStateE.running && BirdSpeedFactor > 0.2f)
             {
                 script = movingAnimationScript;
             }
             if (script != lastscript)
             {
                 acomp.runtimeAnimatorController = Resources.Load <RuntimeAnimatorController>(script);
                 PersonMan.UnsyncAnimation(acomp, script, "BirdCtrl");
                 //acomp.Play(script, 0, GraphAlgos.GraphUtil.GetRanFloat(0, 1));// unsync the animations for birdctrl
             }
             if (person)
             {
                 person.perstate = PersonAniStateE.walking;
             }
             //Debug.Log("animationScript:" + movingAnimationScript + " loaded");
         }
         else
         {
             Debug.Log("Could not find animatior component on birdformgo");
         }
     }
 }
Exemplo n.º 2
0
 // Use this for initialization
 void Start()
 {
     sman     = FindObjectOfType <SceneMan>();
     linkctrl = sman.linkcloudman;
     gm       = sman.gaman;
     bm       = sman.bdman;
     pm       = sman.psman;
     zm       = sman.znman;
 }
Exemplo n.º 3
0
        public Person MakePerson(GenderE gender, string persname, string avname, empStatusE empstatus, bool hasHololens = false, bool flagged = false)
        {
            var pgo = new GameObject(persname);

            pgo.transform.position = Vector3.zero;
            pgo.transform.parent   = this.transform;
            var pers = pgo.AddComponent <Person>();

            pers.AddPrsDetails(this, gender, persname, avname, empstatus, hasHololens);
            AddPersonToCollection(pers); /// has to be afterwards because of the sorted names for journeys
            pers.idleScript  = PersonMan.GetIdleScript(pers.avatarName);
            pers.walkScript  = "PersonRunning";
            pers.danceScript = "Samba Dancing";
            pers.flagged     = flagged;
            return(pers);
        }
Exemplo n.º 4
0
 public void AddPrsDetails(PersonMan pm, PersonMan.GenderE gender, string persname, string avatarname, PersonMan.empStatusE empstat, bool hasHololens = false)
 {
     this.pm           = pm;
     this.bm           = pm.sman.bdman;
     this.personGender = gender;
     this.personName   = persname;
     this.avatarName   = avatarname;
     this.idleScript   = "";
     this.walkScript   = "";
     this.danceScript  = "";
     this.placeBld     = "";
     this.placeNode    = "";
     this.perstate     = PersonAniStateE.standing;
     this.homeBld      = "";
     this.homeRoom     = "";
     this.homeNode     = "";
     this.empStatus    = empstat;
     this.hasHololens  = hasHololens;
     //this.prsgos = new List<GameObject>();
 }
Exemplo n.º 5
0
 public void EverybodyDance(bool dodance)
 {
     Debug.Log("Everybody Dance " + dodance);
     if (dodance != _dancing)
     {
         _dancing = dodance;
         foreach (var pers in persnamelookup.Values)
         {
             if (pers.perstate == PersonAniStateE.standing)
             {
                 var acomp  = pers.persGo.gameObject.GetComponent <Animator>();
                 var script = pers.danceScript;
                 if (!_dancing)
                 {
                     script = pers.idleScript;
                 }
                 acomp.runtimeAnimatorController = Resources.Load <RuntimeAnimatorController>("Animations/" + script);
                 PersonMan.UnsyncAnimation(acomp, script, "EverybodyDance");
             }
         }
     }
 }
Exemplo n.º 6
0
        public void CreateObjects()
        {
            // have to defer
            //Debug.Log("start slot");

            if (slotformgo != null)
            {
                DeleteGos();
                //Debug.Log("opps slotformgo should be null:" + slotformgo.name);
            }

            this.slotformgo = new GameObject(name + "_formgo_" + instance);
            instance++;
            slotformgo.transform.parent = this.transform;
            var zm = zone.zm;
            var slotformselector = zm.slotform;
            //Debug.Log("Generating slotform:" + slotformselector);
            bool createfloor   = zm.showFloor;
            bool createparkbox = zm.showParkbox;
            bool createsign    = zm.showSign;
            bool createnode    = zm.showNode;
            bool createperson  = zm.showPerson;

            if (createfloor)
            {
                floor = GameObject.CreatePrimitive(PrimitiveType.Cube);
                floor.transform.parent = slotformgo.transform;
                floor.name             = "floor";
                var floorwid = 1.0f;
                floorwid = zone.slot2slotdist;
                floor.transform.localScale = new Vector3(slotlen, 0.01f, floorwid);
                var crenderer = floor.GetComponent <Renderer>();
                crenderer.material.color  = Color.gray;
                crenderer.material.shader = Shader.Find("Diffuse");
                //map.AddDrawingElement(new OnlineMapsDrawingRect(new Vector2(2, 2), new Vector2(1, 1), Color.green, 1,Color.blue));
                var clrdr = floor.GetComponent <Collider>();
                clrdr.enabled = false;
            }
            if (createparkbox)
            {
                parkbox = GameObject.CreatePrimitive(PrimitiveType.Cube);
                parkbox.transform.parent     = slotformgo.transform;
                parkbox.transform.localScale = new Vector3(slotlen, slothit, slotwid);
                parkbox.transform.position   = new Vector3(0f, 0.9f, 0f);
                parkbox.name = "parkbox";
                var pbrenderer = parkbox.GetComponent <Renderer>();
                pbrenderer.material.color  = new Color(0.5f, 0.5f, 0.5f, 0.5f); // transparent gray
                pbrenderer.material.shader = Shader.Find("Transparent/Diffuse");
                var clrdr = parkbox.GetComponent <Collider>();
                clrdr.enabled = false;
            }
            if (createsign)
            {
                sign = GameObject.CreatePrimitive(PrimitiveType.Cube);
                sign.transform.parent     = slotformgo.transform;
                sign.name                 = "sign";
                sign.transform.localScale = new Vector3(0.1f, 0.5f, 1f);
                //        sign.transform.rotation = Quaternion.Euler(0, 90, 0);
                sign.transform.position = new Vector3(slotlen / 2, 1.2f, 0);
                SetSlotState(slotstate);
                var clrdr = sign.GetComponent <Collider>();
                clrdr.enabled = false;
            }
            if (createnode)
            {
                //var node = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                var cclr = (occupied ? "red" : "cyan");
                var node = GraphAlgos.GraphUtil.CreateMarkerSphere("node", Vector3.zero, clr: cclr);
                node.transform.parent = slotformgo.transform;
                //var rrenderer = node.GetComponent<Renderer>();
                //rrenderer.material.color = (occupied ? Color.red : Color.cyan);
            }

            if (createperson && occupied)
            {
                //var objPrefab = getpersgo(avatarname);
                //if (objPrefab==null)
                //{
                //    Debug.Log("Could not fetch obj " + avatarname+" for "+persname);
                //    return;
                //}
                //persgo = Instantiate<GameObject>(objPrefab);
                //var animator = persgo.GetComponent<Animator>();
                //animator.applyRootMotion = false;
                //var script = PersonMan.GetIdleScript(avatarname, persgo);
                //animator.runtimeAnimatorController = Resources.Load<RuntimeAnimatorController>("Animations/"+script);

                persgo = person.LoadPersonGo("-ava-zs");
                var animator = persgo.GetComponent <Animator>();
                animator.applyRootMotion = false;
                var script = person.idleScript;
                person.perstate = PersonAniStateE.standing;

                animator.runtimeAnimatorController = Resources.Load <RuntimeAnimatorController>("Animations/" + script);
                PersonMan.UnsyncAnimation(animator, script, "ZoneSlot");

                persgo.name               = persname;
                persgo.transform.parent   = slotformgo.transform;
                persgo.transform.position = slotformgo.transform.position;
                persgo.transform.rotation = slotformgo.transform.rotation;
                persgo.transform.Rotate(new Vector3(0, avatarrotate, 0));
                if (person.hasHololens)
                {
                    person.ActivateHololens(true);
                }
                if (person.hasCamera)
                {
                    person.AddCamera(persgo, "ZoneSlot CreateObjects");
                }
                if (person.grabbedMainCamera)
                {
                    person.GrabMainCamera();
                }
            }
            calcVeks();
            slotformgo.transform.position = new Vector3(x, 0, z);
            slotformgo.transform.rotation = Quaternion.Euler(0, ang + 90, 0);
        }
Exemplo n.º 7
0
        public void CreateObjects()
        {
            // have to defer
            //Debug.Log("start slot");

            if (roomformgo != null)
            {
                DeleteGos();
                //Debug.Log("opps slotformgo should be null:" + slotformgo.name);
            }

            this.roomformgo = new GameObject(name + "_form_go" + instance);
            instance++;
            roomformgo.transform.parent = this.transform;
            //Debug.Log("Generating roomformgo:" + roomformselector);
            bool createfloor = true;

            if (!occman)
            {
                Debug.LogWarning("occman is null in BldRoom for building " + bld.name);
            }
            bool createperson = occman && occman.GetPersonCount() > 0;
            bool createnodes  = occman && bm.sman.linkcloudman.nodesvisible;

            if (createfloor)
            {
                var floor = GameObject.CreatePrimitive(PrimitiveType.Cube);
                floor.transform.parent     = roomformgo.transform;
                floor.name                 = "floor";
                floor.transform.localScale = new Vector3(length, 0.01f, width);
                var crenderer = floor.GetComponent <Renderer>();
                crenderer.material.color  = Color.gray;
                crenderer.material.shader = Shader.Find("Diffuse");
                //map.AddDrawingElement(new OnlineMapsDrawingRect(new Vector2(2, 2), new Vector2(1, 1), Color.green, 1,Color.blue));
            }
            if (createperson)
            {
                for (int i = 0; i < occman.GetPersonCount(); i++)
                {
                    var pers = occman.GetPersonN(i);
                    //if (pers.personName.Contains("Arnie"))
                    //{
                    //    Debug.Log("Creating ava for " + pers.personName + " i:" + i);
                    //}
                    var persgo     = pers.LoadPersonGo("-ava-br");
                    var idlescript = pers.idleScript;
                    var animator   = persgo.GetComponent <Animator>();
                    //if (pers.personName=="Yuka Althoff")
                    //{
                    //    Debug.Log("Creating yuka");
                    //}
                    animator.applyRootMotion = false;
                    pers.perstate            = PersonAniStateE.standing;

                    //idlescript = "Samba Dancing";
                    animator.runtimeAnimatorController = Resources.Load <RuntimeAnimatorController>("Animations/" + idlescript);
                    PersonMan.UnsyncAnimation(animator, idlescript, "BldRoom");
                    //var aclip = animator.runtimeAnimatorController.animationClips[0];
                    //animator.Play(idlescript, 0, GraphAlgos.GraphUtil.GetRanFloat(0, 1) );// unsync the animations
                    //var ctrl = animator.runtimeAnimatorController;
                    //animation["Idle"].time = Random.Range(0.0, animation["Idle"].length);

                    pers.roomPogo = persgo;
                    //persgo.name = pers.personName+"-ava";
                    if (!pers.UseFixedPlace())
                    {
                        persgo.transform.position = roomformgo.transform.position;
                    }
                    else
                    {
                        var lclc   = bm.sman.linkcloudman;
                        var nodept = lclc.GetNode(pers.homeNode);
                        var roompt = lclc.GetNode(this.roomNodeName);
                        var diff   = nodept.pt - roompt.pt;
                        //var roomrotate = Quaternion.EulerAngles(0, this.alignang, 0);// wierd, apparently EulerAngles is in Radians?
                        var roomrotate = Quaternion.Euler(0, r2d * this.alignang, 0);
                        var diffa      = roomrotate * diff;
                        persgo.transform.position = diffa;
                    }

                    persgo.transform.SetParent(roomformgo.transform);
                    ////pogo.transform.Rotate(roomformgo.transform.rotation.eulerAngles);

                    if (pers.hasCamera)
                    {
                        pers.AddCamera(persgo, "BldRoom CreateObjects");
                    }
                    if (pers.hasHololens)
                    {
                        pers.ActivateHololens(true);
                    }
                    if (pers.grabbedMainCamera)
                    {
                        pers.GrabMainCamera();
                    }

                    if (!pers.UseFixedPlace())
                    {
                        var v = occman.GetOccPosition(pers.roomPlaceIdx);
                        //if (bld.name == "Bld19" && (pers.homeRoom=="b19-f01-lobby"))
                        //{
                        //    Debug.Log(pers.personName + " in " + pers.placeNode + "  idx:" + pers.placeIdx + " personCap:" + personCap + " ang:" + ang/d2r+" x:"+x+" z:"+z);
                        //}
                        persgo.transform.Translate(new Vector3(v.x, 0, v.z));
                        var rang = r2d * occman.GetOccAngle(pers.roomPlaceIdx);

                        persgo.transform.Rotate(new Vector3(0, 270 - rang, 0));
                    }
                    else
                    {
                        persgo.transform.Rotate(new Vector3(0, pers.homeRotate, 0));
                    }
                }
            }
            if (createnodes)
            {
                occman.CreateNodes();
            }
            roomformgo.transform.position = pos;
            roomformgo.transform.rotation = Quaternion.Euler(0, alignang, 0);
        }