Ejemplo n.º 1
0
        IEnumerator EmeraldGolemEssence_MovementCoroutine(On.EmeraldGolemEssence.orig_MovementCoroutine orig, EmeraldGolemEssence self)
        {
            DynData <EmeraldGolemEssence> selfData = new DynData <EmeraldGolemEssence>(self);
            Vector3        startPos   = selfData.Get <Vector3>("startPos");
            Vector3        targetPos  = startPos;
            Vector3        vel        = Vector3.zero;
            float          maxVel     = 10f;
            float          accel      = 0.5f;
            List <Vector3> movePoints = new List <Vector3>
            {
                new Vector3(regularBeginPos.x - 10f, regularBeginPos.y),
                new Vector3(regularBeginPos.x - 10f, regularBeginPos.y + 6f),
                new Vector3(regularBeginPos.x + 10f, regularBeginPos.y),
                new Vector3(regularBeginPos.x + 10f, regularBeginPos.y + 6f)
            };
            int     idx  = -1;
            Vector3 ab3  = targetPos - self.transform.position;
            float   xDir = Mathf.Sign(ab3.x);
            float   yDir = Mathf.Sign(ab3.y);

            while (true)
            {
                ab3  = targetPos - self.transform.position;
                vel += ab3.normalized * accel;
                if (vel.magnitude > maxVel)
                {
                    vel.Normalize();
                    vel *= maxVel;
                }
                self.transform.position += vel * TimeVars.GetDeltaTime();
                if (Mathf.Sign(ab3.x) != Mathf.Sign(xDir) || Mathf.Sign(ab3.y) != Mathf.Sign(yDir))
                {
                    if (idx != -1)
                    {
                        List <Vector3> list = new List <Vector3>(movePoints);
                        list.RemoveAt(idx);
                        idx = UnityEngine.Random.Range(0, list.Count);
                    }
                    else
                    {
                        idx = UnityEngine.Random.Range(0, movePoints.Count);
                    }
                    targetPos = movePoints[idx];
                    ab3       = targetPos - self.transform.position;
                    xDir      = Mathf.Sign(ab3.x);
                    yDir      = Mathf.Sign(ab3.y);
                }
                yield return(null);
            }
        }
        public static IEnumerator GoToQuadSineWaveCoroutine(this LeafGolemProjectile self, Vector3 targetPosition, float duration)
        {
            Vector3 startPos = self.transform.position;
            float   progress = 0f;

            while (progress < 1f)
            {
                progress += TimeVars.GetDeltaTime() / duration;
                float tweenProgress = TweenFunctions.Quadratic.Out(0f, 1f, progress);
                float x             = Vector3.Lerp(startPos, targetPosition, tweenProgress).x;
                float y             = targetPosition.y - 1 + Mathf.Cos(6 * Mathf.PI * progress) / 2;
                self.transform.position = new Vector3(x, y, self.transform.position.z);
                yield return(null);
            }
            self.Raise("onReachedPosition", EventArgs.Empty);
        }
Ejemplo n.º 3
0
        void PoisonArrow_Update(On.PoisonArrow.orig_Update orig, PoisonArrow self)
        {
            DynData <PoisonArrow> selfData = new DynData <PoisonArrow>(self);

            if (selfData.Get <bool>("movementStarted"))
            {
                int          layerMask    = LayerMaskConstants.GROUND_8_AND_16 | LayerMaskConstants.HITTABLE | LayerMaskConstants.MOVING_COLLISION_8_AND_16;
                RaycastHit2D raycastHit2D = Manager <DimensionManager> .Instance.MultiDimensionRaycast(self.transform.position + new Vector3(selfData.Get <Vector2>("dir").x, selfData.Get <Vector2>("dir").y) * 1.25f, selfData.Get <Vector2>("dir"), selfData.Get <float>("speed") *TimeVars.GetDeltaTime(), layerMask, false, false, true);

                if (raycastHit2D.transform != null && (raycastHit2D.transform.gameObject.layer != LayerConstants.HITTABLE || raycastHit2D.transform.gameObject.tag == "SkullMount"))
                {
                    try {
                        if (selfData.Get <bool>("bounceAtWall"))
                        {
                            self.OverrideDir(new Vector2(selfData.Get <NecromancerBoss>("necromancerRef").transform.localScale.x, 0f));
                            selfData.Set("bounceAtWall", false);
                        }
                    } catch (Exception e) {
                        CourierLogger.LogDetailed(e);
                    }
                }
            }
            orig(self);
        }