Inheritance: MonoBehaviour
Beispiel #1
0
        /// <summary>
        /// Bites the lure with the given fish.
        /// </summary>
        /// <param name="fish">The biting fish.</param>
        /// <returns>True if the bite hooked the fish; otherwise, false.</returns>
        public bool BiteLure(Fish fish)
        {
            bool hooked = Lure.BiteLure(fish, _hookedFish);

            if (hooked)
            {
                if (_hookedFish == null)
                {
                    _hookedFish = fish;
                    OnFishingEvent(FishingEvent.FishHooked);
                }
                else
                {
                    _hookedFish.OnEaten();
                    OnFishingEvent(FishingEvent.FishEaten);
                    _hookedFish = fish;
                }
            }
            else
            {
                if (_hookedFish != null)
                {
                    _hookedFish.OnEaten();
                    OnFishingEvent(FishingEvent.FishEaten);
                    _hookedFish = null;
                }
                _lureBroken = true;
                OnFishingEvent(FishingEvent.LureBroke);
            }
            return(hooked);
        }
        private void UpdateLure(Lure lure)
        {
            var index = MyLures.IndexOf(lure);

            MyLures.Remove(lure);
            MyLures.Insert(index, lure);
        }
Beispiel #3
0
 /// <summary>
 /// Gets the sprite of the specified lure.
 /// </summary>
 private Sprite GetLureSprite(Lure lure)
 {
     if (lure == Lures.Basic)
     {
         return(_sprite.GetSprite("Basic"));
     }
     if (lure == Lures.Small)
     {
         return(_sprite.GetSprite("Small"));
     }
     if (lure == Lures.SmallUpgraded)
     {
         return(_sprite.GetSprite("SmallUpgraded"));
     }
     if (lure == Lures.Medium)
     {
         return(_sprite.GetSprite("Medium"));
     }
     if (lure == Lures.Large)
     {
         return(_sprite.GetSprite("Large"));
     }
     if (lure == Lures.LargeUpgraded)
     {
         return(_sprite.GetSprite("LargeUpgraded"));
     }
     return(null);
 }
Beispiel #4
0
        public async Task <IActionResult> Edit(int id, [Bind("LureId,Brand,Type,Color")] Lure lure)
        {
            if (id != lure.LureId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(lure);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LureExists(lure.LureId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(lure));
        }
Beispiel #5
0
 /// <summary>
 /// Gets the localized name of the specified lure.
 /// </summary>
 private string GetLureName(Lure lure)
 {
     if (lure == Lures.Basic)
     {
         return(Resources.StoreLureBasic);
     }
     if (lure == Lures.Small)
     {
         return(Resources.StoreLureSmall);
     }
     if (lure == Lures.SmallUpgraded)
     {
         return(Resources.StoreLureSmallUpgraded);
     }
     if (lure == Lures.Medium)
     {
         return(Resources.StoreLureMedium);
     }
     if (lure == Lures.Large)
     {
         return(Resources.StoreLureLarge);
     }
     if (lure == Lures.LargeUpgraded)
     {
         return(Resources.StoreLureLargeUpgraded);
     }
     return(String.Empty);
 }
Beispiel #6
0
 // Start is called before the first frame update
 void Start()
 {
     Mode         = FishingMode.waiting;
     Lure         = GameObject.Find("Lure").GetComponent <Lure>();
     LeftButton   = GameObject.Find("LeftButton").GetComponent <LeftButton>();
     RightButton  = GameObject.Find("RightButton").GetComponent <RightButton>();
     ActionButton = GameObject.Find("ActionButton").GetComponent <ActionButton>();
 }
Beispiel #7
0
 /// <summary>
 /// Returns true if the given fish should chase the lure; otherwise, false.
 /// </summary>
 public bool IsAttractedToLure(Fish fish)
 {
     if (_lureBroken || _lurePosition.Y <= _scene.WaterLevel)
     {
         return(false);
     }
     return(Lure.IsAttractedTo(fish, _hookedFish));
 }
Beispiel #8
0
        public async Task <IActionResult> Create([Bind("LureId,Brand,Type,Color")] Lure lure)
        {
            if (ModelState.IsValid)
            {
                _context.Add(lure);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(lure));
        }
Beispiel #9
0
 private void Awake()
 {
     if (_instance != null && _instance != this)
     {
         Destroy(this.gameObject);
     }
     else
     {
         _instance = this;
     }
 }
Beispiel #10
0
 public void startFishing(Lure cause)
 {
     isBusy     = true;
     lure       = cause;
     isDying    = true;
     deathTime  = deathTime * (.5f + Random.value);
     dyingTimer = deathTime;
     deathCause = DeathCause.Lure;
     lure.gameObject.SetActive(true);
     lure.addTarget(this);
     lure.Reset();
 }
 internal void HideOrShowLureDetails(Lure lure)
 {
     if (!lure.IsVisible)
     {
         lure.IsVisible = true;
     }
     else
     {
         lure.IsVisible = false;
     }
     UpdateLure(lure);
 }
Beispiel #12
0
    void lureReleaseListener(Message message)
    {
//		if (true)
//			return;
        LureReleasedMessage lureMessage = message as LureReleasedMessage;

        if (lureMessage.NPC.Equals(gameObject))
        {
            lured    = false;
            lastLure = lureMessage.Lure;
            //TODO: make getNextPath better
            nextPath = getNextPath();
        }
    }
Beispiel #13
0
        public static List <GearItem> CreateLuresByID(params int[] luresID)
        {
            List <GearItem> result = new List <GearItem>();

            foreach (int ID in luresID)
            {
                Lure standardLure = (Lure)_standardItems.FirstOrDefault(lure => lure.ItemtypeID == ID);

                if (standardLure != null)
                {
                    result.Add(standardLure.Clone());
                }
            }

            return(result);
        }
Beispiel #14
0
        public void UseItem(GearItem item)
        {
            switch (item)
            {
            case FishingRod rod:
            {
                CurrentRod = rod;
                RaiseMessage(string.Format("Your current rod is {0}", rod.Name));
                break;
            }

            case Reel reel:
            {
                InstallReel(reel);
                break;
            }

            case FishingLine line:
            {
                InstallLine(line);
                break;
            }

            case Lure lure:
            {
                CurrentLure = lure;
                RaiseMessage(string.Format("Current lure is {0} ({1} portions left)", lure.OriginalName, lure.PortionsLeft));
                break;
            }

            case HooksSet hooksSet:
            {
                CurrentRod.InstallHook(hooksSet.TakeOneHook());
                RaiseMessage(string.Format("You install {0} on {1}", hooksSet.Hook.Name, CurrentRod.Name));
                break;
            }
            }

            RaiseBackpackChanged();
        }
Beispiel #15
0
        /// <summary>
        /// Loads the sprites necessary to display this state.
        /// </summary>
        public void LoadContent(ContentManager content)
        {
            RodSprites = new Dictionary <RodType, Sprite>();
            for (RodType rod = RodType.Bronze; rod <= RodType.Legendary; rod++)
            {
                Sprite rodSprite = content.Load <SpriteDescriptorTemplate>("Sprites/Fishing/Rod" + rod.ToString()).Create().Sprite;
                rodSprite.Position += _scene.PlayerPosition;
                RodSprites.Add(rod, rodSprite);
            }

            LureSprites = new Dictionary <Lure, Sprite>();
            for (int i = 0; i < FishingGirl.Gameplay.Lures.AllLures.Length; i++)
            {
                Lure   lure       = FishingGirl.Gameplay.Lures.AllLures[i];
                Sprite lureSprite = content.Load <SpriteDescriptorTemplate>("Sprites/Fishing/" + lure.SpriteName).Create().Sprite;
                LureSprites.Add(lure, lureSprite);
            }

            LineSprite = content.Load <SpriteDescriptorTemplate>("Sprites/Fishing/Line").Create().Sprite;

            // set up the lure now that we know what the rod looks like
            _lurePosition = GetRodTipPosition() + new Vector2(5f, 15f);
        }
	public LureReleasedMessage (Lure lure, GameObject npc):base(MessageType.LureReleased)
	{
		Lure = lure;
		NPC = npc;
	}
    // Update is called once per frame
    void Update()
    {
        Debug.DrawLine(transform.position, agent.destination);

        currentLureInRange = GetLureInRange();
        // Check for Closest Stag every 20 sec (and lure)
        if (checkCounter <= 0.0f)
        {
            findClosestPlayer();
        }
        else
        {
            checkCounter -= Time.deltaTime;
        }

        if (Input.GetKeyDown(KeyCode.Space))

        {
            StartCoroutine(Fade());
        }
        //Debug.Log(currentState);
        if (actionTimer > 0)
        {
            actionTimer -= Time.deltaTime;
        }
        else
        {
            switchActions = true;
        }

        if (currentState == AIStates.Idle)
        {
            //DeerSound.clip = DeerSounds[1];
            if (player)
            {
                agent.SetDestination(RandomNavSphere(transform.position, Random.Range(1, 2.4f)));
                currentState = AIStates.Running;
                SwitchAnimationState(currentState);
            }
            else
            {
                actionTimer = Random.Range(4, 12);
                Debug.Log(actionTimer);

                PlayerChecked = false;
                currentState  = AIStates.Standing;
                SwitchAnimationState(currentState);


                previousIdlePoints.Add(transform.position);
                if (previousIdlePoints.Count > 5)
                {
                    previousIdlePoints.RemoveAt(0);
                }
            }
        }
        else if (currentState == AIStates.Roaming)
        {
            agent.speed = RoamingSpeed;
            //DeerSound.clip = DeerSounds[1];

            if (DoneReachingDestination())
            {
                currentState = AIStates.Idle;
                if (targetedLure)
                {
                    //Deactivate lure
                    currentLureInRange.DeactivateLure();
                }
            }
        }
        else if (currentState == AIStates.Standing)
        {
            bool PathClear;
            if (switchActions)
            {
                //Debug.Log("True");

                /*if (!animator || animator.GetCurrentAnimatorStateInfo(0).normalizedTime - Mathf.Floor(animator.GetCurrentAnimatorStateInfo(0).normalizedTime) > 0.99f)
                 * {*/
                //Debug.Log("Here");
                do
                {
                    //if (!animator || animator.GetCurrentAnimatorStateInfo(0).normalizedTime - Mathf.Floor(animator.GetCurrentAnimatorStateInfo(0).normalizedTime) > 0.99f)
                    //{
                    if (currentLureInRange != null && currentLureInRange.spawnedEffect)
                    {
                        agent.destination = currentLureInRange.transform.position;
                        targetedLure      = true;
                    }
                    else
                    {
                        agent.destination = RandomNavSphere(transform.position, Random.Range(5, 120));
                    }

                    agent.CalculatePath(agent.destination, navMeshPath);

                    if (navMeshPath.status != NavMeshPathStatus.PathComplete)
                    {
                        if (currentLureInRange != null)
                        {
                            currentLureInRange = null;
                        }
                        PathClear = false;
                        //Debug.Log("Can't go there");
                    }
                    else
                    {
                        //Debug.Log("Path Clear");
                        PathClear = true;
                    }
                    //}
                    //else
                    //{
                    //    PathClear = false;
                    //}
                } while (!PathClear);
                currentState = AIStates.Roaming;
                SwitchAnimationState(currentState);
                /*}*/
            }
        }
        else if (currentState == AIStates.Alert)
        {
            if (switchActions)
            {
                currentState   = AIStates.Idle;
                DeerMaxVision  = 10f;
                alreadylooking = false;
            }
            else if (player && alreadylooking)
            {
                float near = (transform.position - player.position).sqrMagnitude;

                if (near < 15)
                {
                    currentState   = AIStates.Running;
                    DeerMaxVision  = 10f;
                    alreadylooking = false;
                }
            }
        }
        else if (currentState == AIStates.Running)
        {
            agent.speed = RunningSpeed;
            //DeerSound.clip = DeerSounds[0];

            if (player)
            {
                if (reverseFlee)
                {
                    if (DoneReachingDestination() && timeStuck < 0)
                    {
                        if (targetedLure)
                        {
                            //Deactivate lure
                            currentLureInRange.DeactivateLure();
                            targetedLure = false;
                        }

                        reverseFlee = false;
                    }
                    else
                    {
                        timeStuck -= Time.deltaTime;
                    }
                }
                else
                {
                    Vector3 runTo = transform.position + ((transform.position - player.position) * multiplier);
                    distance = (transform.position - player.position).sqrMagnitude;

                    //Find the closest NavMesh edge
                    NavMeshHit hit;
                    if (NavMesh.FindClosestEdge(transform.position, out hit, NavMesh.AllAreas))
                    {
                        closestEdge    = hit.position;
                        distanceToEdge = hit.distance;
                        //Debug.DrawLine(transform.position, closestEdge, Color.red);
                    }

                    if (distanceToEdge < 1f)
                    {
                        if (timeStuck > 1.5f)
                        {
                            if (previousIdlePoints.Count > 0)
                            {
                                runTo       = previousIdlePoints[Random.Range(0, previousIdlePoints.Count - 1)];
                                reverseFlee = true;
                            }
                        }
                        else
                        {
                            timeStuck += Time.deltaTime;
                        }
                    }

                    if (distance < howfardeerhastorun * howfardeerhastorun)
                    {
                        agent.SetDestination(runTo);
                    }
                    else
                    {
                        player        = null;
                        PlayerChecked = false;
                    }
                }

                //Temporarily switch to Idle if the Agent stopped
                if (agent.velocity.sqrMagnitude < 0.1f * 0.1f)
                {
                    SwitchAnimationState(AIStates.Idle);
                }
                else
                {
                    SwitchAnimationState(AIStates.Running);
                }
            }
            else
            {
                //Check if we've reached the destination then stop running
                if (DoneReachingDestination())
                {
                    if (targetedLure)
                    {
                        //Deactivate lure
                        currentLureInRange.DeactivateLure();
                    }

                    actionTimer  = Random.Range(1.4f, 3.4f);
                    currentState = AIStates.Standing;
                    SwitchAnimationState(AIStates.Idle);
                }
            }
        }
        switchActions = false;
    }
	public LureEnteredMessage(Lure lure, GameObject npc):base(MessageType.LureRadiusEntered){
		Lure = lure;
		NPC = npc;
	}
 public LureEnteredMessage(Lure lure, GameObject npc) : base(MessageType.LureRadiusEntered)
 {
     Lure = lure;
     NPC  = npc;
 }
Beispiel #20
0
 public LureReleasedMessage(Lure lure, GameObject npc) : base(MessageType.LureReleased)
 {
     Lure = lure;
     NPC  = npc;
 }
Beispiel #21
0
 // Start is called before the first frame update
 void Start()
 {
     lure           = GameObject.Find("Lure").GetComponent <Lure>();
     fishingManager = GameObject.Find("Game").GetComponent <FishingManager>();
 }
Beispiel #22
0
	void lureReleaseListener (Message message)
	{
		if (true)
			return;
		LureReleasedMessage lureMessage = message as LureReleasedMessage;
		if (lureMessage.NPC.Equals (gameObject)) {
			lured = false;
			lastLure = lureMessage.Lure;
			//TODO: make getNextPath better
			nextPath = getNextPath ();
		}
	}