예제 #1
0
        private void SetupOverlayActionButtons(string itemId, string itemType, XmlNode assetsNode)
        {
            LocalAvatarEntity localAvatarEntity = GameFacade.Instance.RetrieveMediator <AvatarMediator>().LocalAvatarEntity;

            switch (itemType)
            {
            case ItemType.TOPS:
            case ItemType.PANTS:
            case ItemType.SKIRT:
            case ItemType.BAGS:
            case ItemType.SHOES:
            case ItemType.HAIR:
            case ItemType.BODY:
            case ItemType.MAKEUP:
            case ItemType.FACE:
            case ItemType.MOOD:
                // Call method to apply clothing to body
                localAvatarEntity.ApplyTempClothingToAvatar(assetsNode);
                break;

            case ItemType.EMOTE:
                string animationNameString = assetsNode.SelectSingleNode("Asset/AssetData/AnimationName").InnerText;
                animationNameString = animationNameString.Split(' ')[0];
                RigAnimationName animationName = (RigAnimationName)Enum.Parse(typeof(RigAnimationName), animationNameString);
                GameFacade.Instance.RetrieveProxy <AnimationProxy>().SetRigAnimationAssetInfo(animationName, new ClientAssetInfo(assetsNode.SelectSingleNode("Asset")));
                GameFacade.Instance.RetrieveProxy <ClientAssetRepository>().GetAsset <RigAnimationAsset>(new ClientAssetInfo(assetsNode.SelectSingleNode("Asset")), delegate(RigAnimationAsset animationAsset)
                {
                    GameFacade.Instance.SendNotification(GameFacade.PLAY_EMOTE, animationNameString as object);
                });
                break;
            }
        }
예제 #2
0
        public override void BuildEntity()
        {
            base.BuildEntity();
            mLocalAvatarEntity           = new LocalAvatarEntity(mAvatar, this.LoadAvatarAndHeadGameObjects().Second);
            this.AvatarEntity            = mLocalAvatarEntity;
            this.AvatarEntity.AvatarName = this.AvatarName;

            GameFacade.Instance.RetrieveMediator <SchedulerMediator>().Scheduler.StartCoroutine(WaitForAnimationProxyToLoadThenLoadAvatar(this.AvatarDna, mLocalAvatarEntity));
        }
예제 #3
0
        private void UpdateAvatarWithPurchasedItems(XmlDocument xmlResponse)
        {
            LocalAvatarEntity localAvatarEntity = GameFacade.Instance.RetrieveMediator <AvatarMediator>().LocalAvatarEntity;
            XmlNodeList       xmlNodes          = xmlResponse.SelectNodes("Response/purchaseResults/purchaseResult/offer/item/Assets");

            foreach (XmlNode assetsNode in xmlNodes)
            {
                localAvatarEntity.ApplyAssetsToAvatar(assetsNode);
            }
        }
예제 #4
0
        private void SetupOverlayActionButtons(string itemId, string itemType, XmlNode assetsNode)
        {
            // Setup action buttons specific to the item type
            mOverlayRemoveButton.ClearOnPressedActions();

            LocalAvatarEntity localAvatarEntity = GameFacade.Instance.RetrieveMediator <AvatarMediator>().LocalAvatarEntity;

            switch (itemType)
            {
            case ItemType.ROOM_BACKDROP:
                RoomManagerProxy roomManagerProxy = GameFacade.Instance.RetrieveProxy <RoomManagerProxy>();
                if (roomManagerProxy.IsRoomOwner())
                {
                    ApplyImageToRoom(itemId);
                }
                else
                {
                    mOverlayRemoveButton.Disable();
                }
                break;

            case ItemType.TOPS:
            case ItemType.PANTS:
            case ItemType.SKIRT:
            case ItemType.BAGS:
            case ItemType.SHOES:
            case ItemType.MAKEUP:
                // Call method to apply clothing to body
                localAvatarEntity.ApplyTempClothingToAvatar(assetsNode);

                mOverlayRemoveButton.Enable();
                mOverlayRemoveButton.Text = Translation.REMOVEIT;
                mOverlayRemoveButton.AddOnPressedAction(delegate()
                {
                    //Remove clothing method.
                    localAvatarEntity.RemoveClothingFromAvatar(assetsNode);
                    mOverlayWindow.Showing = false;
                });
                break;

            case ItemType.FACE:
            case ItemType.HAIR:
            case ItemType.BODY:
                // Call method to apply clothing to body
                localAvatarEntity.ApplyTempClothingToAvatar(assetsNode);

                mOverlayRemoveButton.Disable();
                break;
            }
        }
예제 #5
0
 public void AddLocalAvatarEntity(LocalAvatarEntity localAvatar, DistributedObjectId doId)
 {
     if (mLocalAvatarEntity != null)
     {
         Console.LogError("The local avatar should only be built once.  if we are seeing this message then this function be being used incorrectly.  this system is flimsy and the assumption that mLocalAvatarEntity has to be null might be incorrect.  if you see this message and it's still not crunch month look into this.");
     }
     if (localAvatar == null)
     {
         throw new ArgumentNullException("localAvatar");
     }
     if (doId == null)
     {
         throw new ArgumentNullException("doId");
     }
     mLocalAvatarEntity = new Pair <DistributedObjectId, LocalAvatarEntity>(doId, localAvatar);
 }
예제 #6
0
        protected override void LoadAssetsCoroutine(XmlDocument assetItemsDoc, AvatarEntity avatarEntity)
        {
            LocalAvatarEntity     localAvatarEntity     = avatarEntity as LocalAvatarEntity;
            ClientAssetRepository clientAssetRepository = GameFacade.Instance.RetrieveProxy <ClientAssetRepository>();

            if (clientAssetRepository == null)
            {
                throw new Exception("Cannot LoadAssets until the ClientAssetRepository is set up (it's set up during the APPLICATION_INIT notification.");
            }

            List <AssetInfo> requestedAssetInfos = new List <AssetInfo>(ParseAssetInfos(assetItemsDoc));

            clientAssetRepository.GetAssets <Asset>(requestedAssetInfos, delegate(IEnumerable <Asset> assets)
            {
                localAvatarEntity.SetDnaAndBuildAvatar(requestedAssetInfos as IEnumerable <AssetInfo>, AvatarEntityLoadedCallback);
            });
        }
        private void SetupMovementInput()
        {
            InputManagerMediator inputManager = GameFacade.Instance.RetrieveMediator <InputManagerMediator>();
            LocalAvatarEntity    localAvatar  = GameFacade.Instance.RetrieveMediator <AvatarMediator>().LocalAvatarEntity;

            mMotor = new Motor(localAvatar);

            mInputReceipts.Add(inputManager.RegisterForButtonDown(KeyCode.Mouse0, ClickToWalk));
            mInputReceipts.Add(inputManager.RegisterForButtonDown(KeyCode.LeftArrow, MoveLeft));
            mInputReceipts.Add(inputManager.RegisterForButtonUp(KeyCode.LeftArrow, StopLeft));
            mInputReceipts.Add(inputManager.RegisterForButtonDown(KeyCode.RightArrow, MoveRight));
            mInputReceipts.Add(inputManager.RegisterForButtonUp(KeyCode.RightArrow, StopRight));
            mInputReceipts.Add(inputManager.RegisterForButtonDown(KeyCode.UpArrow, MoveUp));
            mInputReceipts.Add(inputManager.RegisterForButtonUp(KeyCode.UpArrow, StopUp));
            mInputReceipts.Add(inputManager.RegisterForButtonDown(KeyCode.DownArrow, MoveDown));
            mInputReceipts.Add(inputManager.RegisterForButtonUp(KeyCode.DownArrow, StopDown));
        }
예제 #8
0
        public Motor(LocalAvatarEntity localAvatarEntity)
        {
            mLocalAvatarEntity = localAvatarEntity;
            GameObject gameObjectToMotorize = localAvatarEntity.UnityGameObject;

            if (gameObjectToMotorize == null)
            {
                throw new ArgumentNullException("gameObjectToMotorize");
            }

            mRigidBody = gameObjectToMotorize.GetComponent(typeof(Rigidbody)) as Rigidbody;
            if (mRigidBody == null)
            {
                mRigidBody = gameObjectToMotorize.AddComponent(typeof(Rigidbody)) as Rigidbody;
            }

            mScheduler = GameFacade.Instance.RetrieveMediator <SchedulerMediator>().Scheduler;

            mCollisionReceipt = CollisionUtility.ListenForCollisions(mRigidBody, StopMovingWhenHitGround);
        }
예제 #9
0
        protected override void AvatarEntityLoadedCallback(AvatarEntity avatar)
        {
            Console.WriteLine("LocalAvatarEntityLoadedCallback");

            base.AvatarEntityLoadedCallback(avatar);

            mLocalAvatarEntity = avatar as LocalAvatarEntity;
            if (mLocalAvatarEntity == null)
            {
                throw new Exception("Could not cast avatarEntity as LocalAvatarEntity");
            }

            PhysicMaterial physMaterial = new PhysicMaterial("Main Character Physics Material");

            physMaterial.bouncyness         = 0.0f;
            physMaterial.dynamicFriction    = 0.0f;
            physMaterial.dynamicFriction2   = 0.0f;
            physMaterial.frictionDirection  = Vector3.zero;
            physMaterial.frictionDirection2 = Vector3.zero;
            physMaterial.frictionCombine    = PhysicMaterialCombine.Minimum;
            physMaterial.staticFriction     = 0.0f;
            physMaterial.staticFriction2    = 0.0f;

            CapsuleCollider capsuleCollider = mAvatar.AddComponent(typeof(CapsuleCollider)) as CapsuleCollider;

            capsuleCollider.material = physMaterial;

            Rigidbody rigidbody = mAvatar.GetComponent(typeof(Rigidbody)) as Rigidbody;

            if (rigidbody == null)
            {
                rigidbody = mAvatar.AddComponent(typeof(Rigidbody)) as Rigidbody;
            }
            rigidbody.freezeRotation   = true;
            rigidbody.detectCollisions = true;
            rigidbody.angularDrag      = 0.0f;

            Component[] renderers = mAvatar.GetComponentsInChildren(typeof(Renderer));
            foreach (Component c in renderers)
            {
                Renderer r = c as Renderer;
                for (int x = 0; x < r.materials.Length; ++x)
                {
                    Texture2D tex    = r.materials[x].mainTexture as Texture2D;
                    Shader    shader = Shader.Find("Avatar/Saturation Shader");
                    r.materials[x]             = new Material(shader);
                    r.materials[x].mainTexture = tex;
                }
            }

            XmlDocument avatarProperties = XmlUtility.LoadXmlDocument("resources://XmlDocuments/FirstMilestone/PrototypeAvatarProperties");

            try
            {
                // Randomize the starting position in X and Z
                List <float> xPositions = new List <float>();
                List <float> zPositions = new List <float>();
                for (int i = -2; i <= 2; ++i)
                {
                    xPositions.Add(0.5f * i);
                }
                for (int j = 0; j <= 6; ++j)
                {
                    zPositions.Add(0.5f * j);
                }
                int   xIndex    = new System.Random().Next(xPositions.Count);
                int   zIndex    = new System.Random().Next(zPositions.Count);
                float xPosition = xPositions[xIndex];
                float zPosition = zPositions[zIndex];
                float yPosition = 0.02221f;

                mAvatar.transform.position = new Vector3(xPosition, yPosition, zPosition);

                XmlNode colliderNode = avatarProperties.SelectSingleNode("/Avatar/collider");

                capsuleCollider.center = new Vector3(float.Parse(colliderNode.SelectSingleNode("center/x").InnerText),
                                                     float.Parse(colliderNode.SelectSingleNode("center/y").InnerText),
                                                     float.Parse(colliderNode.SelectSingleNode("center/z").InnerText));

                capsuleCollider.height = float.Parse(colliderNode.SelectSingleNode("height").InnerText);
                capsuleCollider.radius = float.Parse(colliderNode.SelectSingleNode("radius").InnerText);
            }
            catch (NullReferenceException e)
            {
                throw new Exception("Error loading XML from 'resources://XmlDocuments/FirstMilestone/PrototypeAvatarProperties'", e);
            }
            catch (FormatException e)
            {
                throw new Exception("Error loading XML from 'resources://XmlDocuments/FirstMilestone/PrototypeAvatarProperties'", e);
            }
            catch (XmlException e)
            {
                throw new Exception("Error loading XML from 'resources://XmlDocuments/FirstMilestone/PrototypeAvatarProperties'", e);
            }

            this.Entity = mLocalAvatarEntity;

            this.Coroutines.Add(Scheduler.StartCoroutine(TelemetryBroadcast()));

            GameFacade.Instance.RetrieveMediator <AvatarMediator>().AddLocalAvatarEntity(mLocalAvatarEntity, this.DistributedObjectId);

            mLocalAvatarStateMachine = new LocalAvatarStateMachine(mLocalAvatarEntity);
            GameFacade.Instance.RegisterMediator(mLocalAvatarStateMachine);

            GameFacade.Instance.SendNotification(GameFacade.LOCAL_AVATAR_LOADED);

            base.AvatarEntityLoadedRunBufferedMessages();
        }
 public LocalAvatarAnimationStateMachine(LocalAvatarEntity avatarEntity)
     : base(avatarEntity)
 {
 }
예제 #11
0
 public DefaultLocalAvatarState(LocalAvatarEntity avatarEntity)
     : base(avatarEntity)
 {
     mLocalAvatarEntity = avatarEntity;
 }
예제 #12
0
        public LocalAvatarStateMachine(LocalAvatarEntity localAvatarEntity)
        {
            mDefaultLocalAvatarState = new DefaultLocalAvatarState(localAvatarEntity);

            this.EnterInitialState(mDefaultLocalAvatarState);
        }