public LandNPCMovementOrder GetLandNpcNextWaypoint(int pathId, int currWaypoint, EnumRouteFollowerDirections direction) { if (!m_isActive) { return(new LandNPCMovementOrder()); } Vector3 waypoint; switch (direction) { case EnumRouteFollowerDirections.Forward: currWaypoint++; if (currWaypoint >= m_routesWaypoints[pathId].Length) { currWaypoint = 0; } break; case EnumRouteFollowerDirections.Backward: currWaypoint--; if (currWaypoint < 0) { currWaypoint = m_routesWaypoints[pathId].Length - 1; } break; } waypoint = m_routesWaypoints[pathId][currWaypoint]; return(new LandNPCMovementOrder(waypoint, currWaypoint, direction)); }
public void SpawnLandNpcAtRandom() { // 1. Select a route int routeId = Random.Range(0, m_routesCount - 1); // 2. Select a spawn waypoint and direction int spawnWaypointId = Random.Range(0, m_routesWaypoints[routeId].Length - 1); Vector3 spawnWaypoint = m_routesWaypoints[routeId][spawnWaypointId]; EnumRouteFollowerDirections direction = Random.value > .5 ? EnumRouteFollowerDirections.Forward : EnumRouteFollowerDirections.Backward; // 3. Spawn NPC LandEnemyBehavior npcBehavior = Instantiate(landNpcPrefab, spawnWaypoint, Quaternion.identity).GetComponent <LandEnemyBehavior>(); // 4. Assign route parameters npcBehavior.SetInitialRouteValues(routeId, spawnWaypointId, spawnWaypoint, direction); npcBehavior.damage = landDamage; npcBehavior.rewardPoints = landReward; npcBehavior.moveSpeed = landSpeed; npcBehavior.player = player; npcBehavior.Initialize(); }
public LandNPCMovementOrder(Vector3 waypointLoc, int waypointNum, EnumRouteFollowerDirections moveDirection) { waypoint = waypointLoc; waypointId = waypointNum; direction = moveDirection; }