Example #1
0
        public void SetMovement(NPCMovement state)
        {
            if (this.movement == state)
            {
                return;
            }

            if (this.gVob != null && !this.IsDead && this.Model.GetActiveAniFromLayerID(1) == null &&
                !this.Environment.InAir && (gVob.BitField1 & zCVob.BitFlag0.physicsEnabled) == 0)
            {
                if (this.movement == NPCMovement.Right || this.movement == NPCMovement.Left)
                {
                    if (state == NPCMovement.Forward)
                    {
                        gModel.StartAni(gAI._s_walkl, 0);
                    }
                    else
                    {
                        gModel.StartAni(gAI._s_walk, 0);
                    }
                }
            }

            this.movement = state;

            guidedNextUpdate = 0;
            this.OnTick(GameTime.Ticks);
        }
Example #2
0
    private void SceneManager_sceneLoaded(Scene arg0, LoadSceneMode arg1)
    {
        if (dad == null)
        {
            dad = this.GetComponent <ToggleDad>();
        }
        if (npc == null)
        {
            npc = this.gameObject.GetComponent <NPCMovement>();
        }

        if (CheckpointValues.CurrentState > GameState.FindClothes /*&& CheckpointValues.CurrentState < GameState.GoToDriverAfterBurger*/)
        {
            npc.Positions.Clear();
            npc.transform.position = grillTransform2.transform.position;
            PutOnProperSpotHack(grillTransform2);
            npc.transform.localEulerAngles = new Vector3(0, -90, 0);
            dad.TurnOnGrillDad();
        }

        //else if (CheckpointValues.CurrentState > GameState.GoToDriverAfterBurger)
        //{
        //    dad.TurnOnNormalDad();
        //    npc.Positions.Clear();
        //    npc.transform.position = awayFromGrillTransform.transform.position;
        //    PutOnProperSpotHack(awayFromGrillTransform);
        //    npc.transform.localEulerAngles = new Vector3(0, -90, 0);
        //}
    }
Example #3
0
            public static void ReadPosAng(PacketReader stream, GameClient client, World world)
            {
                int id = stream.ReadUShort();

                if (world.TryGetVob(id, out NPC npc) && (npc.guide == client || npc.client == client))
                {
                    var oldPos      = npc.Position;
                    var oldAng      = npc.Angles;
                    var oldMovement = npc.Movement;

                    var pos      = stream.ReadCompressedPosition();
                    var ang      = stream.ReadCompressedAngles();
                    int bitfield = stream.ReadShort();

                    bool           inAir      = (bitfield & 0x8000) != 0;
                    NPCMovement    movement   = (NPCMovement)((bitfield >> 12) & 0x7);
                    float          waterDepth = ((bitfield >> 6) & 0x3F) / (float)0x3F;
                    float          waterLevel = (bitfield & 0x3F) / (float)0x3F;
                    VobEnvironment env        = new VobEnvironment(inAir, waterLevel, waterDepth);

                    npc.movement    = movement;
                    npc.environment = env;

                    npc.SetPosAng(pos, ang, client);

                    if (npc == client.Character)
                    {
                        client.UpdateVobList(world, pos);
                    }

                    OnNPCMove?.Invoke(npc, oldPos, oldAng, oldMovement);
                }
            }
    void Start()
    {
        movement = GetComponent <NPCMovement>();
        stats    = GetComponent <NPCStats>();

        attackReady = true;
    }
Example #5
0
        void UpdateGuidedNPCPosition(long now, long interval, float minPosDist, float minAngDist)
        {
            if (now < guidedNextUpdate)
            {
                return;
            }

            Vec3f          pos = this.Position;
            Angles         ang = this.Angles;
            VobEnvironment env = this.Environment;

            if (now - guidedNextUpdate < TimeSpan.TicksPerSecond)
            {
                // nothing really changed, only update every second
                if (guidedLastMovement == this.movement &&
                    pos.GetDistance(guidedLastPos) < minPosDist &&
                    !ang.DifferenceIsBigger(guidedLastAng, minAngDist) &&
                    env == guidedLastEnv)
                {
                    return;
                }
            }

            guidedLastMovement = this.movement;
            guidedLastPos      = pos;
            guidedLastAng      = ang;
            guidedLastEnv      = env;

            Messages.WritePosAngMessage(this, pos, ang, env);

            guidedNextUpdate = now + interval;

            //this.ScriptObject.OnPosChanged();
        }
Example #6
0
 protected virtual void Awake()
 {
     pInput       = GameObject.FindObjectOfType <PlayerInput>();
     npcMovement  = this.GetComponent <NPCMovement>();
     soundManager = this.GetComponent <SoundManager>();
     ShowChatIcon(false);
 }
Example #7
0
    public void UnGrab()
    {
        _npcMovement = null;
        pnjGrab      = null;
        _movement.DontKeepWeb();
        rb.isKinematic = false;
        rb.velocity    = Vector2.zero;
        animator.SetBool("IsGrab", false);
        _movement.enabled = true;
        if (!_movement.IsOnWeb)
        {
            _movement.ShootWeb(Vector2.up);
        }

        transform.parent = null;

        npcCursor?.ShowNPC(null);

        PnjGrabbed = null;
        IsGrab     = false;

        AudioBox.Instance?.PlaySoundOneShot(SoundOneShot.SpiderUngrab);

        InputManager.Input.Spider.Web.Enable();
        InputManager.Input.Spider.Swing.Enable();
        InputManager.Input.Spider.Slide.Enable();
    }
Example #8
0
	public void Setup (NPCMovement movement)
    {
        nodes = GameManager.AllNodes;
        this.currentNPC = movement;
        this.pathList = new List<Node>();
        this.AttainedFinalNode = false;
	}
Example #9
0
        static void NPCInst_sOnNPCInstMove(NPCInst npc, Vec3f oldPos, Angles oldAng, NPCMovement oldMovement)
        {
            if (npc.IsDead || !npc.IsPlayer || npc.IsUnconscious)
            {
                return;
            }

            ArenaClient client = (ArenaClient)npc.Client;

            if (client.HordeClass == null)
            {
                return;
            }

            if (ActiveStandInst != null)
            {
                return;
            }

            foreach (var s in ActiveStands)
            {
                if (npc.GetPosition().GetDistance(s.Stand.Position) < s.Stand.Range)
                {
                    StartStand(s);
                    break;
                }
            }
        }
Example #10
0
    private void Grab(GameObject pnj)
    {
        pnjGrab      = pnj;
        _npcMovement = pnjGrab.GetComponent <NPCMovement>();
        _movement.KeepWeb();
        rb.isKinematic = true;
        rb.velocity    = Vector3.zero;
        animator.SetBool("IsGrab", true);
        _movement.enabled = false;

        RaycastHit2D hit = Physics2D.Raycast(transform.position, pnj.transform.position - transform.position, 100f, LayerMask.GetMask("PasserbyLayer"));

        if (hit.collider != null)
        {
            if (hit.collider.bounds.Contains(transform.position))
            {
                //transform.position = hit.collider.transform.position;
                NPC.PasserbyDescription passer = hit.collider.GetComponent <NPC.PasserbyDescription>();
                if (passer)
                {
                    transform.position = passer.Center.position;
                }
                else
                {
                    transform.position = hit.collider.transform.position;
                }
                sprite.gameObject.transform.rotation = Quaternion.Euler(0, 0, 180);
                animator.SetBool("InsidePnj", true);
            }
            else
            {
                float z = Vector3.Angle(transform.up, hit.normal);
                if (hit.normal.x > 0)
                {
                    z *= -1;
                }
                sprite.gameObject.transform.rotation = Quaternion.Euler(0, 0, z);
                transform.position = hit.point + hit.normal * grabOffsetPos;
                animator.SetBool("InsidePnj", false);
            }
        }
        else
        {
            transform.LookAt(Vector2.up);
        }

        transform.parent = pnj.transform;

        npcCursor?.ShowNPC(pnj);

        PnjGrabbed = pnj;
        IsGrab     = true;

        AudioBox.Instance?.PlaySoundOneShot(SoundOneShot.SpiderGrab);

        InputManager.Input.Spider.Web.Disable();
        InputManager.Input.Spider.Swing.Disable();
        InputManager.Input.Spider.Slide.Disable();
    }
Example #11
0
 //Instantiate an agent on a random cell
 private void InstantiateAgents(int num)
 {
     for (int i = 0; i < num; i++)
     {
         NPCMovement aiInstance = Instantiate(agentPrefab) as NPCMovement;
         aiInstance.SetLocation(_mazeInstance.rooms[i].RandomCell);
         aiInstance.name = "Agent N°" + i;
     }
 }
Example #12
0
        /*
         * basis -> item = iteminstance <- scripts
         * basis -> iteminstance = itemdefinition <- scripts
         */

        public void SetMovement(NPCMovement state)
        {
            if (state == this.Movement)
            {
                return;
            }

            BaseInst.SetMovement(state);
        }
Example #13
0
 protected void Awake()
 {
     dialogueSystem  = GetComponent <DialogueSystem>();
     dialogueManager = (DialogueManager)FindObjectOfType(typeof(DialogueManager));
     movement        = GetComponent <NPCMovement>();
     counterPosition = GameObject.Find("CounterPosition").transform.position;
     gm       = FindObjectOfType <GameManager>();
     animator = GetComponent <Animator>();
 }
Example #14
0
 // Use this for initialization
 void Start()
 {
     animator         = GetComponent <Animator>();
     npcMovement      = GetComponent <NPCMovement>();
     npcAttack        = GetComponent <NPCAttack>();
     npcVision        = GetComponent <NPCVision>();
     HitColliders     = GetComponentsInChildren <DamageZone>();
     PlayerController = FindObjectOfType <PlayerController>();
     ActivateHitColliders();
 }
Example #15
0
    private void Start()
    {
        movement = GetComponent <NPCMovement>();
        combat   = GetComponent <EnemyCombat>();
        ai       = GetComponent <NPCAI>();

        // spawnPoint = transform.position;
        spawnPoint = transform.localPosition;

        curState = EnemyStates.Wandering;
    }
Example #16
0
 private void Awake()
 {
     animator = this.GetComponent <Animator>();
     npc      = this.GetComponentInParent <NPC>();
     NpcMove  = this.GetComponentInParent <NPCMovement>();
     //if (npc != null) { NPC.DetectedBigfootEvent += PlayReactionAnimation; }
     if (NpcMove != null)
     {
         NpcMove.MoveStateChanged += MoveAnimationStateChanged;
     }
 }
Example #17
0
 //General notes:
 //RANGES
 //Long range behavior of the basic baddy: approach in "travel mode" then transition to mid range mode
 //Mid range: try to bait player into attacking with dodge patterns, leaving the player to whiff
 //Melee range: defined as the range in which a dash attack has a high chance of success unless there is a dedicated dodge or shield
 //Point blank range: defined as the range in which a melee attack will definitely hit its target unless shielded
 void Start()
 {
     dirs            = new Vector2[16];
     cb              = GetComponent <EnemyBehavior>();
     playerTransform = GameManager.GM.playerTransform;
     path            = GetComponentInChildren <LineSegment>();
     aggression      = (Random.Range(0, 1) <= attackOdds);
     //        StartCoroutine(Approach());
     npcm     = GetComponent <NPCMovement>();
     startPos = new Vector2(transform.position.x, transform.position.y);
 }
Example #18
0
    public override void UpdateMove(float deltaTime)
    {
        if (timeToNextMove <= 0)
        {
            moveDir        = NPCMovement.ChaoticMovementAdditive(moveDir, 0.5f, speed);
            timeToNextMove = Random.Range(0.1f, 0.35f);
        }
        timeToNextMove -= deltaTime;

        character.transform.Translate(moveDir * deltaTime);
    }
    IEnumerator DestinationChange(NPCMovement NPC)
    {
        while (!NPC.NPCCanMove)
        {
            yield return(new WaitForSeconds(Wait));
        }
        yield return(new WaitForSeconds(Wait));

        NPC.speed     = newspeed;
        NPC.Direction = NewDestination;
    }
Example #20
0
    protected void OnTriggerExit2D(Collider2D other)
    {
        //Debug.Log ("[ColliderAggro] OnCollisionExit2D");

        if (other.gameObject.tag == "Player" || other.gameObject.tag == "Aggroable")
        {
            //Debug.Log ("Exited Aggro CollideBox");
            //On veut qu'il suive la cible
            NPCMovement monsterController = this.GetComponentInParent <NPCMovement> ();
            monsterController.state = NPCMovement.States.goalLess;
        }
    }
 private void Awake()
 {
     parent   = this.transform.parent.GetComponentInChildren <NPC>();
     switcher = parent.GetComponentInChildren <PhoneSwitcher>();
     parent.SawDisguisedBigfootEvent += AddTimesSeen;
     SeenEvent += ReactToBigfootMinor;
     movement   = parent.GetComponent <NPCMovement>();
     BoxCollider[] colls = parent.GetComponents <BoxCollider>();
     parentTrigger = System.Array.Find(colls, x => x.isTrigger);
     progression   = this.GetComponent <ProgressiveAgent>();
     sManager_ref  = FindObjectOfType <SubtitleManager>().GetComponent <SubtitleManager>();
 }
    void Start()
    {
        combat   = GetComponent <NPCCombat>();
        movement = GetComponent <NPCMovement>();

        currentHP = maxHP;

        navAgent = GetComponent <NavMeshAgent>();

        //DEBUG
        targetSprite.SetActive(false);
    }
    // Start is called before the first frame update
    void Start()
    {
        this.avoiderComponent = this.GetComponent <Avoider>();

        this.movement = this.GetComponent <NPCMovement>();

        Animator animator = this.GetComponent <Animator>();

        headTransform = animator.GetBoneTransform(HumanBodyBones.Head);

        this.isShyNPC = Random.Range(0.0f, 1.0f) > 0.5f;
        this.preferredLookAwayDirection = new Vector3(Random.Range(-20f, 20f), Random.Range(-20f, 20f), 0.0f);
    }
Example #24
0
    private void OnEnable()
    {
        animator    = GetComponent <Animator>();
        npcMovement = GetComponent <NPCMovement>();
        npcAttack   = GetComponent <NPCAttack>();
        npcVision   = GetComponent <NPCVision>();

        NPCMovement.ActivateNavAgent();
        npcVision.enabled = true;
        HitColliders      = GetComponentsInChildren <DamageZone>();
        PlayerController  = FindObjectOfType <PlayerController>();
        ActivateHitColliders();
        Dead = false;
    }
Example #25
0
    protected void OnTriggerStay2D(Collider2D other)
    {
        //Debug.Log ("[ColliderAggro] OnCollisionStay2D");

        if (other.gameObject.tag == "Player" || other.gameObject.tag == "Aggroable")
        {
            //Debug.Log ("Stayed Aggro CollideBox");
            //On veut qu'il suive la cible
            NPCMovement monsterController = this.GetComponentInParent <NPCMovement> ();
            Vector2     newTarget         = other.transform.position;
            monsterController.currentGoal = newTarget;
            monsterController.state       = NPCMovement.States.attacking;
        }
    }
Example #26
0
File: NPC.cs Project: Kimsy99/c-19
    void Awake()
    {
        spriteFlippable2D = GetComponent <SpriteFlippable2D>();
        flashable         = GetComponent <Flashable>();
        health            = GetComponent <NPCHealth>();
        movement          = GetComponent <NPCMovement>();
        Transform weaponHolderTransform = transform.Find("WeaponHolder");

        if (weaponHolderTransform != null)
        {
            weaponHolder = weaponHolderTransform.gameObject;
        }
        heldWeapon = GetComponentInChildren <NPCHeldWeapon>();
    }
Example #27
0
    void Start()
    {
        GameObject gameManager = GameObject.Find("GameManager");

        componentSpawner = gameManager.GetComponent <FloatingComponentSpawner>();
        shipManager      = gameManager.GetComponent <ShipManager>();
        shipManager.OnShipDestroyed.AddListener(OnShipDestroyed);

        movement      = GetComponent <NPCMovement>();
        shipStructure = GetComponent <ShipStructure>();
        fsm           = StateMachine <States> .Initialize(this);

        fsm.ChangeState(States.Roam);
    }
 void OnTriggerEnter2D(Collider2D NPC)
 {
     if (NPC.tag == "NPC")
     {
         NPCMovement Movement = NPC.gameObject.GetComponent <NPCMovement>();
         Movement.Direction = Vector2.zero;
         if (ActivateDialog)
         {
             NPC.gameObject.GetComponent <ActivateDialog>().Activate(NewDialog, TypeSpeed);
             Movement.NPCCanMove = false;
         }
         StartCoroutine(DestinationChange(Movement));
     }
 }
Example #29
0
    private void Start()
    {
        _currentState = State.Idle;

        _movementController = GetComponent <NPCMovement>();
        _meshDestroyer      = GetComponentInChildren <MeshDestroy>();
        _animAI             = GetComponent <Animator>();
        _navmeshAgent       = GetComponent <NavMeshAgent>();
        _health             = GetComponent <Health>();


        attackAnimations = new List <AttackAnimationInfo>();
        attackAnimations.Add(new AttackAnimationInfo("jab", 0.375f));
        attackAnimations.Add(new AttackAnimationInfo("cross", 0.458f));
    }
    void Spawn()
    {
        // Instantiate a new NPCMovement object at a random spawn position based on parameters
        Vector3     spawnPosition = this.gameObject.transform.position + Random.Range(-0.5f, 0.5f) * spawnSize;
        NPCMovement npc           = Instantiate(npcPrefab, spawnPosition, this.gameObject.transform.rotation);

        // Set the walking data for the NPC
        npc.SetWalkingData(this.maxSpeed, npcWalkingDirection);

        //Randomize new spawntime based on user parameters
        float randomTime = Random.Range(minSpawnTime, maxSpawnTime);

        // Invoke a new spawn at a random time
        Invoke("Spawn", randomTime);
    }
Example #31
0
	// Use this for initialization
	void Start () {
	This = transform;
	//get an instance of class of NPC movement
	movement = GetComponent<NPCMovement>();
	//if navigation data is loaded,
		if(Pathfinding.DataLoaded())
		//then set initial data:)
			SetInitialData ();
		if(cycleRoute){
		if(!Pathfinding.NodesEqual(route[0],route[route.Length-1])){
		cycleRoute = false;		
			}
		}

	}
Example #32
0
    void Start()
    {
        ChangeState(state); //comeca no estado definido no inspector

        gameManager = GameObject.FindObjectOfType(typeof(GameManager)) as GameManager;
        animate     = GetComponent <Animate>();
        status      = GetComponent <Status>();
        movement    = GetComponent <NPCMovement>();
        myRb        = GetComponent <Rigidbody>();
        agent       = GetComponent <NavMeshAgent>();

        status.health     = status.totalHealth;
        sliderHP.maxValue = status.totalHealth;
        AtualizaUI();
    }
Example #33
0
	//Wrapper funtion for chasing the target
	public void Chase(NPCMovement target) {
		float orientationAngle = Vector3.Angle (transform.forward.normalized, (target.transform.position - transform.position).normalized);
		print (orientationAngle);

		if (orientationAngle < 30 || (target.transform.position - transform.position).magnitude < 15) {
			switch (movementType) {
			case(MovementType.KINEMATIC):
				if (chaseType == ChaseType.SEEK) {
					Kinematic_Seek (target);
				}
				else if (chaseType == ChaseType.PURSUIT) {
					Kinematic_Pursuit (target);
				}
				break;
			case(MovementType.STEERING):
				if (chaseType == ChaseType.SEEK) {
					Steering_Seek (target);
				}
				else if (chaseType == ChaseType.PURSUIT) {
					Steering_Pursuit (target);
				}
				break;
			default:
				break;
			}
		}
		else {
			switch (movementType) {
			case (MovementType.KINEMATIC):
				rotateTowards (target.transform.position);
				break;
			case (MovementType.STEERING):
				if (Steering_Stop ()) {
					rotateTowards (target.transform.position);
				}
				break;
			default:
				break;
			}
		}
	}
Example #34
0
	//Evade from the target with the steering evade formula
	public void Steering_Evade (NPCMovement target) {
		float estimatedArrivalTime = (target.transform.position - transform.position).magnitude / maximumSeekVelocity / 2f; //reduced estimated time for better gameplay
		Vector3 nextTargetPosition = target.transform.position + (this.maximumSeekVelocity * estimatedArrivalTime) * target.transform.forward.normalized;
		//Find the direction vector based on the target's future position
		directionVector = (transform.position - nextTargetPosition);
		directionVector.Normalize ();
		//Find the current velocity
		currentRotationVelocity = Mathf.Min (currentRotationVelocity + maxinumRotationAcceleration, maximumRotationVelocity);
		currentVelocity = Mathf.Min (currentVelocity + maximumAcceleration, maximumFleeVelocity);
		//Interpolate the orientation of the NPC object
		Quaternion targetRotation = Quaternion.LookRotation (directionVector);
		transform.rotation = Quaternion.Lerp (transform.rotation, targetRotation, currentRotationVelocity * Time.deltaTime);
		//Update the position
		Vector3 newPosition = transform.position + (currentVelocity * Time.deltaTime) * transform.forward.normalized;
		transform.position = newPosition;
	}
Example #35
0
	//Wrapper function for fleeing from the target
	public void Avoid (NPCMovement target) {
		float orientationAngle = Vector3.Angle (transform.forward.normalized, (transform.position - target.transform.position).normalized);
		print (orientationAngle);
		
		if (orientationAngle < 30 || (target.transform.position - transform.position).magnitude > 18) {
			switch (movementType) {
			case(MovementType.KINEMATIC):
				if (evadeType == EvadeType.FLEE) {
					Kinematic_Flee (target);
				}
				else if (evadeType == EvadeType.EVADE) {
					Kinematic_Evade (target);
				}
				break;
			case(MovementType.STEERING):
				if (evadeType == EvadeType.FLEE) {
					Steering_Flee (target);
				}
				else if (evadeType == EvadeType.EVADE) {
					Steering_Evade (target);
				}
				break;
			default:
				break;
			}
		}
		else if (orientationAngle < 30 || (target.transform.position - transform.position).magnitude < 18) {
			Quaternion prevLook = transform.rotation;
			switch (movementType) {
			case(MovementType.KINEMATIC):
				if (evadeType == EvadeType.FLEE) {
					Kinematic_Flee (target);
				}
				else if (evadeType == EvadeType.EVADE) {
					Kinematic_Evade (target);
				}
				break;
			case(MovementType.STEERING):
				if (evadeType == EvadeType.FLEE) {
					Steering_Flee (target);
				}
				else if (evadeType == EvadeType.EVADE) {
					Steering_Evade (target);
				}
				break;
			default:
				break;
			}
			transform.rotation = prevLook;
		}
		else {
			switch (movementType) {
			case (MovementType.KINEMATIC):
				rotateTowards ((transform.position - target.transform.position) + transform.position);
				break;
			case (MovementType.STEERING):
				if (Steering_Stop ()) {
					rotateTowards ((transform.position - target.transform.position) + transform.position);
				}
				break;
			default:
				break;
			}
		}
	}
Example #36
0
	//Flee from the target with the steering flee formula
	public void Steering_Flee (NPCMovement target) {
		//Find the direction vector based on the target's position
		directionVector = (transform.position - target.transform.position);
		directionVector.Normalize ();
		//Find the current velocity
		currentRotationVelocity = Mathf.Min (currentRotationVelocity + maxinumRotationAcceleration, maximumRotationVelocity);
		currentVelocity = Mathf.Min (currentVelocity + maximumAcceleration, maximumFleeVelocity);
		//Interpolate the orientation of the NPC object
		Quaternion targetRotation = Quaternion.LookRotation (directionVector);
		transform.rotation = Quaternion.Lerp (transform.rotation, targetRotation, currentRotationVelocity * Time.deltaTime);
		//Update the position
		Vector3 newPosition = transform.position + (currentVelocity * Time.deltaTime) * transform.forward.normalized;
		transform.position = newPosition;
	}
Example #37
0
	// Use this for initialization
	void Start () {
		movement = GetComponent <NPCMovement>();
		thisRadius = GetComponent<CapsuleCollider>().radius;
		This = transform;
	}
Example #38
0
	//Evade the target with the kinematic evade formula
	public void Kinematic_Evade (NPCMovement target) {
		float estimatedArrivalTime = (target.transform.position - transform.position).magnitude / maximumSeekVelocity;
		Vector3 nextTargetPosition = target.transform.position + (this.maximumSeekVelocity * estimatedArrivalTime) * target.transform.forward.normalized;
		directionVector = (transform.position - nextTargetPosition);
		directionVector.Normalize ();
		//Interpolate the orientation of the NPC object
		Quaternion targetRotation = Quaternion.LookRotation (directionVector);
		transform.rotation = Quaternion.Lerp (transform.rotation, targetRotation, maximumRotationVelocity * Time.deltaTime);
		Vector3 newPosition = transform.position + (maximumFleeVelocity * Time.deltaTime) * directionVector;
		transform.position = newPosition;
	}
Example #39
0
	//Flee from the target accoding to the kinematic flee formula
	public void Kinematic_Flee (NPCMovement target) {
		directionVector = (transform.position - target.transform.position);
		directionVector.Normalize ();
		//Interpolate the orientation of the NPC object
		Quaternion targetRotation = Quaternion.LookRotation (directionVector);
		transform.rotation = Quaternion.Lerp (transform.rotation, targetRotation, maximumRotationVelocity * Time.deltaTime);
		Vector3 newPosition = transform.position + (maximumFleeVelocity * Time.deltaTime) * directionVector;
		transform.position = newPosition;
	}
Example #40
0
	//Chase the target with the kinematic arrival formula
	public void Kinematic_Arrive (NPCMovement target) {
		//Find the direction vector based on the target's position
		directionVector = (target.transform.position - transform.position);
		directionVector.Normalize ();
		//Find the current velocity by using the T2T method with the target's position
		currentVelocity = (maximumFleeVelocity * (target.transform.position - transform.position).magnitude / 15f);
		if (currentVelocity > maximumFleeVelocity)
			currentVelocity = maximumFleeVelocity;
		//Interpolate the orientation of the NPC object
		Quaternion targetRotation = Quaternion.LookRotation (directionVector);
		transform.rotation = Quaternion.Lerp (transform.rotation, targetRotation, maximumRotationVelocity * Time.deltaTime);
		//Find the next position by: p' = p + v(direction vector)t
		Vector3 newPosition = transform.position + (currentVelocity * Time.deltaTime) * directionVector;
		//Move to the next position
		transform.position = newPosition;
	}
Example #41
0
	//Chase the target with the kinematic seek formula
	public void Kinematic_Seek (NPCMovement target) {
		//Find the direction vector based on the target's position
		directionVector = (target.transform.position - transform.position);
		directionVector.Normalize ();
		//Interpolate the orientation of the NPC object
		Quaternion targetRotation = Quaternion.LookRotation (directionVector);
		transform.rotation = Quaternion.Lerp (transform.rotation, targetRotation, maximumRotationVelocity * Time.deltaTime);
		//Update the position
		Vector3 newPosition = transform.position + (maximumSeekVelocity * Time.deltaTime) * directionVector;
		transform.position = newPosition;
	}
 // Use this for initialization
 void Start()
 {
     Lua.RegisterFunction("AddDeepThoughtDialogue", this, typeof(DeepThoughtManager).GetMethod("AddDeepThoughtDialogue"));
     indexOfList = 0;
     npcMovement = GameObject.Find("NPC").GetComponent<NPCMovement>();
     displayingDT = false;
     canDisplayText = false;
     LastTextLocation = new Vector2(0, 0);
     lastIndex = 0;
     displayReactableDT = false;
     DeepThoughtList = new List<DeepThought>();
     inConversation = ConversationTracker.InConversation;
     dtCounter = 0;
 }