override public float Run() { if (npcToMove) { if (followType == FollowType.StopFollowing) { npcToMove.StopFollowing(); return(0f); } if (followPlayer || charToFollow != (Char)npcToMove) { npcToMove.FollowAssign(charToFollow, followPlayer, updateFrequency, followDistance, followDistanceMax, faceWhenIdle, randomDirection); } } return(0f); }
override public float Run() { if (npcToMove) { if (followType == FollowType.StopFollowing) { npcToMove.FollowReset(); return(0f); } if (followPlayer || charToFollow != (Char)npcToMove) { npcToMove.FollowAssign(charToFollow, followPlayer, updateFrequency, followDistance, followDistanceMax); } } return(0f); }
public override float Run() { if (runtimeNpcToMove) { if (followType == FollowType.StopFollowing) { runtimeNpcToMove.StopFollowing(); return(0f); } if (followPlayer || (runtimeCharToFollow != null && runtimeCharToFollow != (Char)runtimeNpcToMove)) { runtimeNpcToMove.FollowAssign(runtimeCharToFollow, followPlayer, updateFrequency, followDistance, followDistanceMax, faceWhenIdle, randomDirection); } } return(0f); }
public override float Run() { if (runtimeNpcToMove) { if (followType == FollowType.StopFollowing) { runtimeNpcToMove.StopFollowing(); return(0f); } if (runtimeCharToFollow != null) { bool _followPlayer = (runtimeCharToFollow == KickStarter.player); runtimeNpcToMove.FollowAssign(runtimeCharToFollow, _followPlayer, updateFrequency, followDistance, followDistanceMax, faceWhenIdle, randomDirection); } } return(0f); }
public override void LoadData(string stringData) { NPCData data = Serializer.LoadScriptData <NPCData> (stringData); if (data == null) { return; } if (data.isOn) { gameObject.layer = LayerMask.NameToLayer(KickStarter.settingsManager.hotspotLayer); } else { gameObject.layer = LayerMask.NameToLayer(KickStarter.settingsManager.deactivatedLayer); } transform.position = new Vector3(data.LocX, data.LocY, data.LocZ); transform.eulerAngles = new Vector3(data.RotX, data.RotY, data.RotZ); transform.localScale = new Vector3(data.ScaleX, data.ScaleY, data.ScaleZ); if (GetComponent <NPC>()) { NPC npc = GetComponent <NPC>(); npc.EndPath(); if (npc.animationEngine == AnimationEngine.Sprites2DToolkit || npc.animationEngine == AnimationEngine.SpritesUnity) { npc.idleAnimSprite = data.idleAnim; npc.walkAnimSprite = data.walkAnim; npc.talkAnimSprite = data.talkAnim; npc.runAnimSprite = data.runAnim; } else if (npc.animationEngine == AnimationEngine.Legacy) { npc.idleAnim = AssetLoader.RetrieveAsset(npc.idleAnim, data.idleAnim); npc.walkAnim = AssetLoader.RetrieveAsset(npc.walkAnim, data.walkAnim); npc.runAnim = AssetLoader.RetrieveAsset(npc.runAnim, data.talkAnim); npc.talkAnim = AssetLoader.RetrieveAsset(npc.talkAnim, data.runAnim); } else if (npc.animationEngine == AnimationEngine.Mecanim) { npc.moveSpeedParameter = data.walkAnim; npc.talkParameter = data.talkAnim; npc.turnParameter = data.runAnim;; } npc.walkSound = AssetLoader.RetrieveAsset(npc.walkSound, data.walkSound); npc.runSound = AssetLoader.RetrieveAsset(npc.runSound, data.runSound); npc.speechLabel = data.speechLabel; npc.portraitIcon.texture = AssetLoader.RetrieveAsset(npc.portraitIcon.texture, data.portraitGraphic); npc.walkSpeedScale = data.walkSpeed; npc.runSpeedScale = data.runSpeed; // Rendering npc.lockDirection = data.lockDirection; npc.lockScale = data.lockScale; if (npc.spriteChild && npc.spriteChild.GetComponent <FollowSortingMap>()) { npc.spriteChild.GetComponent <FollowSortingMap>().lockSorting = data.lockSorting; } else if (npc.GetComponent <FollowSortingMap>()) { npc.GetComponent <FollowSortingMap>().lockSorting = data.lockSorting; } else { npc.ReleaseSorting(); } if (data.lockDirection) { npc.spriteDirection = data.spriteDirection; } if (data.lockScale) { npc.spriteScale = data.spriteScale; } if (data.lockSorting) { if (npc.spriteChild && npc.spriteChild.GetComponent <Renderer>()) { npc.spriteChild.GetComponent <Renderer>().sortingOrder = data.sortingOrder; npc.spriteChild.GetComponent <Renderer>().sortingLayerName = data.sortingLayer; } else if (npc.GetComponent <Renderer>()) { npc.GetComponent <Renderer>().sortingOrder = data.sortingOrder; npc.GetComponent <Renderer>().sortingLayerName = data.sortingLayer; } } AC.Char charToFollow = null; if (data.followTargetID != 0) { RememberNPC followNPC = Serializer.returnComponent <RememberNPC> (data.followTargetID); if (followNPC.GetComponent <AC.Char>()) { charToFollow = followNPC.GetComponent <AC.Char>(); } } npc.FollowAssign(charToFollow, data.followTargetIsPlayer, data.followFrequency, data.followDistance, data.followDistanceMax); npc.Halt(); if (data.pathData != null && data.pathData != "" && GetComponent <Paths>()) { Paths savedPath = GetComponent <Paths>(); savedPath = Serializer.RestorePathData(savedPath, data.pathData); npc.SetPath(savedPath, data.targetNode, data.prevNode, data.pathAffectY); npc.isRunning = data.isRunning; } else if (data.pathID != 0) { Paths pathObject = Serializer.returnComponent <Paths> (data.pathID); if (pathObject != null) { npc.SetPath(pathObject, data.targetNode, data.prevNode); } else { Debug.LogWarning("Trying to assign a path for NPC " + this.name + ", but the path was not found - was it deleted?"); } } if (data.lastPathID != 0) { Paths pathObject = Serializer.returnComponent <Paths> (data.lastPathID); if (pathObject != null) { npc.SetLastPath(pathObject, data.lastTargetNode, data.lastPrevNode); } else { Debug.LogWarning("Trying to assign the previous path for NPC " + this.name + ", but the path was not found - was it deleted?"); } } // Head target if (data.isHeadTurning) { npc.SetHeadTurnTarget(new Vector3(data.headTargetX, data.headTargetY, data.headTargetZ), true); } else { npc.ClearHeadTurnTarget(true); } } }