Inheritance: MonoBehaviour
    private void IterateBounce(Vector3 newHitPos, Vector3 approachDirection, Vector3 currentHitNormal)
    {
        Vector3    departureDirection = Vector3.Reflect(approachDirection, currentHitNormal);
        GameObject newHit             = new GameObject();

        newHit.transform.position = newHitPos;
        Bounce bounce = newHit.AddComponent(typeof(Bounce)) as Bounce;

        bounce.departureDirection = departureDirection;
        bounce.approachDirection  = approachDirection;
        // Instantiate debug visualizer objects here and attach them as children to newHit
        GameObject dInstance = Instantiate(_debugInstance, newHit.transform.position, newHit.transform.rotation);

        dInstance.transform.SetParent(newHit.transform);
        bounces.Add(newHit);

        if (_bounceCount < _bounceTotal - 1)
        {
            _raycastController.transform.position = newHit.transform.position;
            _raycastController.transform.rotation = Quaternion.FromToRotation(_raycastController.transform.forward, departureDirection);
            _rayComponent = newHit.AddComponent(typeof(BounceRaycastController)) as BounceRaycastController;
            _rayComponent.OnRaycastResult.AddListener(OnRaycastHit);
        }
        _bounceCount++;
    }
Exemplo n.º 2
0
    protected void Move(Board board, Vector2 dir, float dt)
    {
        board.Dir = dir;

        var col = board.MoveAndCollide(board.Velocity * dt);

        if (col != null)
        {
            if (col.Collider is Ball ball)
            {
                ball.Audio.BoardHit();
                ball.CurrentDir = Bounce.BoardBounce(ball, board.Position, board.Extents, col.Position);
            }
            if (col.Collider is BasePowerUp powerUp)
            {
                powerUp.OnCollect();
            }
            else if (col.Collider is StaticBody2D body)
            {
                board.Dir = Vector2.Zero;
                if (PowerupManager.IsTeleportActive &&
                    body.Name == "right_col")
                {
                    stateMachine.ChangeState(nameof(Warping));
                }
            }
            else if (col.Collider is IHittable obj)
            {
                obj.OnHit();
            }
        }
    }
Exemplo n.º 3
0
 void Start()
 {
     Animation      = GetComponentInChildren <Animator> ();
     _sprite        = transform.GetChild(0).gameObject;
     _swordRenderer = Sword.GetComponent <SpriteRenderer> ();
     _bounce        = GetComponent <Bounce> ();
 }
    // Update is called once per frame
    void Update()
    {
        Bounce bounceScript = thePlayer.GetComponent <Bounce> ();

        if (bounceScript.justJump)
        {
            anim.SetBool("Jump", true);
        }
        else
        {
            anim.SetBool("Jump", false);
        }


        if (Input.GetButtonDown("right"))
        {
            gameObject.transform.rotation = Quaternion.Euler(0, -90, 0);
        }
        if (Input.GetButtonDown("left"))
        {
            gameObject.transform.rotation = Quaternion.Euler(0, 90, 0);
        }
        if (Input.GetButtonDown("up"))
        {
            gameObject.transform.rotation = Quaternion.Euler(0, 180, 0);
        }
        if (Input.GetButtonDown("down"))
        {
            gameObject.transform.rotation = Quaternion.Euler(0, 0, 0);
        }
    }
Exemplo n.º 5
0
        public WrapClones(GameObject original, Bounds levelBounds, bool isStatic = false)
        {
            this.original    = original;
            this.levelBounds = levelBounds;
            this.isStatic    = isStatic;
            originalLayer    = original.layer;
            clones           = new GameObject[3]; //max 3 clones for each corner +original
            for (int i = 0; i < clones.Length; i++)
            {
                GameObject clone = GameObject.Instantiate(this.original);



                Component[] components = clone.GetComponentsInChildren(typeof(Component));

                foreach (Component comp in components)
                {
                    if (comp is SpriteRenderer && (comp.gameObject.name == "TAGobj" || comp.gameObject.name == "Chicken" || comp.gameObject.name == "OwnedRenderer"))
                    {
                        if (comp.gameObject.name == "OwnedRenderer")
                        {
                            GameObject.Destroy(comp.gameObject.transform.parent.gameObject);
                        }
                        else
                        {
                            GameObject.Destroy(comp.gameObject);
                        }
                    }

                    if (comp is PlayerHit)
                    {
                        PlayerHit hit = comp as PlayerHit;
                        hit.isClone = true;
                    }
                    if (!(comp is Transform) && !(comp is SpriteRenderer) && !(comp is Collider2D) && !(comp is PlayerHit))
                    {
                        if (comp is LoopOutLevel)
                        {
                            LoopOutLevel loop = comp as LoopOutLevel;
                            loop.isClone = true;
                        }
                        if (comp is Bounce)
                        {
                            Bounce bounce = comp as Bounce;
                            bounce.isClone = true;
                        }
                        //if (comp is PlayerHit) clone.AddComponent<PlayerHitClone>();
                        Destroy(comp);
                    }
                }



                clones[i] = clone;
            }
            foreach (GameObject clone in clones)
            {
                clone.transform.parent = original.transform;
            }
        }
Exemplo n.º 6
0
        public void ShouldReturnNullWriterIfLogOptionsAreNotDescribeTask() {
            var stdout = new StringWriter();
            var b = new Bounce();

            b.LogOptions.DescribeTasks = false;
            Assert.That(b.DescriptionOutput, Is.SameAs(TextWriter.Null));
        }
Exemplo n.º 7
0
        public override YAMLNode ExportYAML(IExportContainer container)
        {
            YAMLMappingNode node = (YAMLMappingNode)base.ExportYAML(container);

            node.AddSerializedVersion(ToSerializedVersion(container.ExportVersion));
            node.Add(TypeName, (int)Type);
            node.Add(CollisionModeName, (int)CollisionMode);
            node.Add(ColliderForceName, ColliderForce);
            node.Add(MultiplyColliderForceByParticleSizeName, MultiplyColliderForceByParticleSize);
            node.Add(MultiplyColliderForceByParticleSpeedName, MultiplyColliderForceByParticleSpeed);
            node.Add(MultiplyColliderForceByCollisionAngleName, GetExportMultiplyColliderForceByCollisionAngle(container.Version));
            node.Add(Plane0Name, Plane0.ExportYAML(container));
            node.Add(Plane1Name, Plane1.ExportYAML(container));
            node.Add(Plane2Name, Plane2.ExportYAML(container));
            node.Add(Plane3Name, Plane3.ExportYAML(container));
            node.Add(Plane4Name, Plane4.ExportYAML(container));
            node.Add(Plane5Name, Plane5.ExportYAML(container));
            node.Add(DampenName, Dampen.ExportYAML(container));
            node.Add(BounceName, Bounce.ExportYAML(container));
            node.Add(EnergyLossOnCollisionName, EnergyLossOnCollision.ExportYAML(container));
            node.Add(MinKillSpeedName, MinKillSpeed);
            node.Add(MaxKillSpeedName, GetExportMaxKillSpeed(container.Version));
            node.Add(RadiusScaleName, GetExportRadiusScale(container.Version));
            node.Add(CollidesWithName, GetExportCollidesWith(container.Version).ExportYAML(container));
            node.Add(MaxCollisionShapesName, GetExportMaxCollisionShapes(container.Version));
            node.Add(QualityName, (int)Quality);
            node.Add(VoxelSizeName, GetExportVoxelSize(container.Version));
            node.Add(CollisionMessagesName, CollisionMessages);
            node.Add(CollidesWithDynamicName, GetExportCollidesWithDynamic(container.Version));
            node.Add(InteriorCollisionsName, InteriorCollisions);
            return(node);
        }
Exemplo n.º 8
0
    void Update()
    {
        Bounce bounceScript = player.GetComponent <Bounce>();

        if (bounceScript.justJump)
        {
            playerAnimator.SetBool("Jump", true);
        }
        else
        {
            playerAnimator.SetBool("Jump", false);
        }



        if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            gameObject.transform.rotation = Quaternion.Euler(0, -90, 0);
        }

        if (Input.GetKeyDown(KeyCode.DownArrow))
        {
            gameObject.transform.rotation = Quaternion.Euler(0, 90, 0);
        }

        if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            gameObject.transform.rotation = Quaternion.Euler(0, 0, 0);
        }

        if (Input.GetKeyDown(KeyCode.LeftArrow))
        {
            gameObject.transform.rotation = Quaternion.Euler(0, 180, 0);
        }
    }
Exemplo n.º 9
0
        public override YAMLNode ExportYAML(IExportContainer container)
        {
#warning TODO: values acording to read version (current 2017.3.0f3)
            YAMLMappingNode node = (YAMLMappingNode)base.ExportYAML(container);
            node.AddSerializedVersion(GetSerializedVersion(container.Version));
            node.Add("type", (int)Type);
            node.Add("collisionMode", (int)CollisionMode);
            node.Add("colliderForce", ColliderForce);
            node.Add("multiplyColliderForceByParticleSize", MultiplyColliderForceByParticleSize);
            node.Add("multiplyColliderForceByParticleSpeed", MultiplyColliderForceByParticleSpeed);
            node.Add("multiplyColliderForceByCollisionAngle", GetExportMultiplyColliderForceByCollisionAngle(container.Version));
            node.Add("plane0", Plane0.ExportYAML(container));
            node.Add("plane1", Plane1.ExportYAML(container));
            node.Add("plane2", Plane2.ExportYAML(container));
            node.Add("plane3", Plane3.ExportYAML(container));
            node.Add("plane4", Plane4.ExportYAML(container));
            node.Add("plane5", Plane5.ExportYAML(container));
            node.Add("m_Dampen", Dampen.ExportYAML(container));
            node.Add("m_Bounce", Bounce.ExportYAML(container));
            node.Add("m_EnergyLossOnCollision", EnergyLossOnCollision.ExportYAML(container));
            node.Add("minKillSpeed", MinKillSpeed);
            node.Add("maxKillSpeed", GetExportMaxKillSpeed(container.Version));
            node.Add("radiusScale", GetExportRadiusScale(container.Version));
            node.Add("collidesWith", GetExportCollidesWith(container.Version).ExportYAML(container));
            node.Add("maxCollisionShapes", GetExportMaxCollisionShapes(container.Version));
            node.Add("quality", (int)Quality);
            node.Add("voxelSize", GetExportVoxelSize(container.Version));
            node.Add("collisionMessages", CollisionMessages);
            node.Add("collidesWithDynamic", GetExportCollidesWithDynamic(container.Version));
            node.Add("interiorCollisions", InteriorCollisions);
            return(node);
        }
Exemplo n.º 10
0
        public MessageWorkerService()
        {
            int workerAmount   = int.Parse(ConfigurationManager.AppSettings["workerAmount"]);
            int highPriority   = int.Parse(ConfigurationManager.AppSettings["highPriority"]);
            int mediumPriority = int.Parse(ConfigurationManager.AppSettings["mediumPriority"]);
            int lowPriority    = int.Parse(ConfigurationManager.AppSettings["lowPriority"]);
            int dumpTimeout    = int.Parse(ConfigurationManager.AppSettings["dumpTimeout"]);

            for (int i = 0; i < workerAmount; ++i)
            {
                workers.Add(new MessageWorker(lowPriority, mediumPriority, highPriority));
            }

            clearClientsQueue = new Bounce(() =>
            {
                foreach (var worker in workers)
                {
                    foreach (var userName in lowClients.Keys)
                    {
                        worker.DoJob(lowClients[userName], mediumClients[userName], highClients[userName]);
                    }
                }
            }, dumpTimeout);
            clearClientsQueue.CallBounce();
        }
Exemplo n.º 11
0
    private void OnCollisionEnter(Collision collision)
    {
        switch (collision.gameObject.tag)
        {
        case "Wall":
            if (delWillSounds != null)
            {
                delWillSounds();    //Send audio of bounce to AudioController
            }
            Transform reference = collision.gameObject.transform.GetChild(0);
            VFX.Instance.bounce.transform.SetParent(reference, false);
            VFX.Instance.bounce.transform.position = new Vector3(reference.position.x, reference.transform.position.y, -1f);
            VFX.Instance.bounce.GetComponent <Animator>().SetTrigger("VFXbounce");
            collision.gameObject.GetComponent <Animator>().SetTrigger("bounce");

            ContactPoint contactWall = collision.contacts[0];
            Vector3      direction   = Vector3.Reflect(updateVelocity.normalized, contactWall.normal);
            Bounce       wallBounce  = collision.gameObject.GetComponent <Bounce>();
            m_Rigidbody.AddForce(direction * wallBounce.Force, ForceMode.Impulse);
            if (wallBounce.fadeOut)
            {
                wallBounce.StartCoroutine("FadeOut");
            }
            break;

        case "LaunchPad":
            ContactPoint contactLaunch = collision.contacts[0];
            Bounce       bounce        = collision.gameObject.GetComponent <Bounce>();
            m_Rigidbody.AddForce(contactLaunch.normal * bounce.Force, ForceMode.Impulse);
            break;

        default:
            break;
        }
    }
 // Use this for initialization
 void Start()
 {
     thePlayer    = GameObject.Find("ParentPlayer");
     level        = GameObject.Find("Level");
     coinParent   = GameObject.Find("CoinParent");
     bounceScript = thePlayer.GetComponent <Bounce>();
 }
Exemplo n.º 13
0
        public void ShouldReturnStdOutIfLogOptionsAreDescribeTask() {
            var stdout = new StringWriter();
            var b = new Bounce();

            b.LogOptions.DescribeTasks = true;
            b.LogOptions.StdOut = stdout;
            Assert.That(b.DescriptionOutput, Is.SameAs(stdout));
        }
Exemplo n.º 14
0
 public static float EaseInOut(float time, float duration, float unusedOvershootOrAmplitude, float unusedPeriod)
 {
     if (time < duration * 0.5f)
     {
         return(Bounce.EaseIn(time * 2f, duration, -1f, -1f) * 0.5f);
     }
     return(Bounce.EaseOut(time * 2f - duration, duration, -1f, -1f) * 0.5f + 0.5f);
 }
Exemplo n.º 15
0
        public void ShouldReturnNullWriterIfLogOptionsAreNotDescribeTask()
        {
            var stdout = new StringWriter();
            var b      = new Bounce();

            b.LogOptions.DescribeTasks = false;
            Assert.That(b.DescriptionOutput, Is.SameAs(TextWriter.Null));
        }
Exemplo n.º 16
0
 // Use this for initialization
 void Start()
 {
     m_bounce = new Bounce();
     m_bounce.Init(Source);
     m_bounce.Target   = Target;
     m_bounce.Value    = Value;
     m_bounce.MaxSpeed = MaxSpeed;
     m_bounce.MinSpeed = MinSpeed;
 }
Exemplo n.º 17
0
        public void ShouldReturnStdOutIfLogOptionsAreDescribeTask()
        {
            var stdout = new StringWriter();
            var b      = new Bounce();

            b.LogOptions.DescribeTasks = true;
            b.LogOptions.StdOut        = stdout;
            Assert.That(b.DescriptionOutput, Is.SameAs(stdout));
        }
Exemplo n.º 18
0
 // Use this for initialization
 void Start()
 {
     m_bounce = new Bounce();
     m_bounce.Init(Source);
     m_bounce.Target = Target;
     m_bounce.Value = Value;
     m_bounce.MaxSpeed = MaxSpeed;
     m_bounce.MinSpeed = MinSpeed;
 }
Exemplo n.º 19
0
        public static float CalculateLerpValueClamp01(float lerpValue, Type easingType, bool isZeroToOne)
        {
            switch (easingType)
            {
            case Type.Linear:
                lerpValue = Linear.InOut(lerpValue);
                break;

            case Type.Quadratic:
                lerpValue = Quadratic.InOut(lerpValue);
                break;

            case Type.Cubic:
                lerpValue = Cubic.InOut(lerpValue);
                break;

            case Type.Quartic:
                lerpValue = Quartic.InOut(lerpValue);
                break;

            case Type.Quintic:
                lerpValue = Quintic.InOut(lerpValue);
                break;

            case Type.Sinusoidal:
                lerpValue = Sinusoidal.InOut(lerpValue);
                break;

            case Type.Exponential:
                lerpValue = Exponential.InOut(lerpValue);
                break;

            case Type.Circular:
                lerpValue = Circular.InOut(lerpValue);
                break;

            case Type.Elastic:
                lerpValue = Elastic.InOut(lerpValue);
                break;

            case Type.Back:
                lerpValue = Back.InOut(lerpValue);
                break;

            case Type.Bounce:
                lerpValue = Bounce.InOut(lerpValue);
                break;

            default:
                return(-1f);
            }

            lerpValue = ClampMinMax(0f, 1f, lerpValue);

            return(lerpValue);
        }
Exemplo n.º 20
0
    void Awake()
    {
        jump   = GetComponent <Jump>();
        bounce = GetComponent <Bounce>();
        patrol = GetComponent <Patrol>();
        chase  = GetComponent <Chase>();
        _hide  = GetComponent <Hide>();
        shape  = GetComponent <ChipmunkShape>();

        PauseGameManager.Instance.register(this, gameObject);
    }
Exemplo n.º 21
0
    // Use this for initialization
    void Start()
    {
        launcher         = GameObject.Find("PlayerThrower").GetComponent <Detach>();
        player           = GameObject.FindGameObjectWithTag("Player");
        obstacleModifier = FindObjectOfType <Bounce>();
        gameScore        = FindObjectOfType <Score>();
        booster          = FindObjectOfType <Jetpack>();
        openShop         = GetComponent <AudioSource>();

        upgradeScreen.SetActive(false);
    }
Exemplo n.º 22
0
 public static float EaseInOut(float t, float b, float c, float d)
 {
     if (t < d / 2)
     {
         return(Bounce.EaseIn(t * 2, 0, c, d) * .5f + b);
     }
     else
     {
         return(Bounce.EaseOut(t * 2 - d, 0, c, d) * .5f + c * .5f + b);
     }
 }
Exemplo n.º 23
0
    private void Start()
    {
        player    = GameObject.FindGameObjectWithTag("Player");
        keepTrack = FindObjectOfType <Score>();
        floor     = FindObjectOfType <Bounce>();
        gameEnd   = FindObjectOfType <BeginRun>();


        moveSpeed  = PlayerPrefs.GetFloat("moveSpeed");
        moveSpeed2 = PlayerPrefs.GetFloat("moveSpeed2");
    }
Exemplo n.º 24
0
 public static float easeInOut(float t)
 {
     if (t <= 0.5f)
     {
         return(Bounce.easeIn(t * 2) / 2);
     }
     else
     {
         return((Bounce.easeOut((t - 0.5f) * 2.0f) / 2) + 0.5f);
     }
 }
Exemplo n.º 25
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         foreach (GameObject item in balls)
         {
             Bounce tmp = item.GetComponent <Bounce>();
             tmp.rabble(Camera.main.ScreenToWorldPoint(Input.mousePosition));
         }
     }
 }
Exemplo n.º 26
0
 /// <summary>
 /// Executes each expression in the list of expressions and returns
 /// evaluated result for each expression through cont parameter.
 /// </summary>
 /// <param name="program">A list of expressions.</param>
 /// <param name="cont">Continuation.</param>
 public void Execute(List <IExpression> program, Cont cont)
 {
     foreach (var expr in program)
     {
         Bounce r = () => Eval(expr, m_Env, cont);
         while (r != null)
         {
             r = r();
         }
     }
 }
Exemplo n.º 27
0
    void Awake()
    {
        jump   = GetComponent <Jump>();
        bounce = GetComponent <Bounce>();
        patrol = GetComponent <Patrol>();
        chase  = GetComponent <Chase>();
        _hide  = GetComponent <Hide>();
        shape  = GetComponent <ChipmunkShape>();

        patrol.setDir(1f);         // initialize patrol direction
        initialPatrolSpeed = patrol.speed;
    }
Exemplo n.º 28
0
    private void Awake()
    {
        if (instance != null)
        {
            Destroy(this.gameObject);
        }
        else
        {
            instance = this;
        }

        cinemachine = FindObjectOfType <CinemachineVirtualCamera>();
    }
Exemplo n.º 29
0
    // Update is called once per frame
    void Update()
    {
        Bounce bouncy = thePlayer.GetComponent <Bounce> ();

        if (bouncy.justJump == true)
        {
            anim.SetBool("Jump", true);
        }
        else
        {
            anim.SetBool("Jump", false);
        }
    }
Exemplo n.º 30
0
        private void Update()
        {
            if (music.timeSamples > samplesPerBeat + lastSample) //If we've reached or overshot the next beat, trigger the event
            {
                lastSample += samplesPerBeat;                    //We set the time of the last sample to the current sample
                Bounce?.Invoke();                                //If anyone is listening for the event, we incoke it
            }

            if (!music.isPlaying)
            {
                music.Play();
            }
        }
Exemplo n.º 31
0
        // ************************** QUEUE CALLBACKS - called from Trampoline/bounce ******************************************************************************


        // -----------------------------------------------------------------------------------
        static Bounce ProcessQueue(Queue <GameEvent> q, DelegateSet delegateSet)
        // -----------------------------------------------------------------------------------
        {
            if (q.Count == 0)
            {
                return(Bounce.End());
            }
            else
            {
                ProcessEvent(q.Peek(), delegateSet);
                q.Dequeue();
                return(Bounce.Continue(q));
            }
        }
Exemplo n.º 32
0
 public DefaultMovementController(string characterName, GameObject character)
 {
     this.characterName     = characterName;
     this.character         = character;
     wanderingFunctions     = new Wandering(this.character);
     pursuingFunctions      = new Pursuing(this.character);
     pathfollowingFunctions = new PathFollowing(this.character, new ArrayList()
     {
         new Vector2(115f, 5f), new Vector2(115f, 10f), new Vector2(120f, 10f), new Vector2(120f, 5f)
     }, true);
     bouncingFunctions     = new Bounce(this.character);
     nearbyPlayerFunctions = new NearbyTarget(this.character, targetPoint, .5f);
     previousLocation      = character.transform.position;
 }
Exemplo n.º 33
0
    // Update is called once per frame
    void Update()
    {
        counter += Time.deltaTime;         // Count up

        // We make sure this is between 0 and TimeToTween because we have the delay added in Start() which causes negative counter
        if (counter >= 0 && counter <= TimeToTween)
        {
            var ratio = counter / TimeToTween;             // We get the ratio of current to our time to tween
            // Use that ratio in the bounce function. This returns a value between 0 and 1 scaled by the tween
            // In this case, bounce causes a 'bounce' on the end (Bounce.Out) of the animation
            var value = Bounce.Out(ratio);
            transform.localScale = new Vector3(value, value, 1);             // We want to tween to 1, so we just use 'value' since we dont need to scale it
        }
    }
Exemplo n.º 34
0
    /// <summary>
    /// Constructs the pane with all the sprites.
    /// </summary>
    public DemoSpriteBounce()
    {
        // Create the basics
        sprites = new SpriteList();
        viewport = new SpriteViewport(sprites);
        viewport.BackgroundColor = new Color(0, 0, 50);

        // Load in a basic drawable
        IDrawable drawable = DemoSprites.PixbufFactory.Create("green-sphere");

        // Create the sprites
        for (int i = 0; i < 20; i++)
        {
            Bounce sprite = new Bounce(drawable);
            sprite.Width = sprite.Height = 64;
            sprites.Add(sprite);
        }
    }
Exemplo n.º 35
0
		public static void ScanDir(string[] strings, string[] args)
		{
			if (args.Length == 0)
			{
				//args = new string[] { @"C:\EMLs" };
				throw new Exception("first argumant should be directory to scan...");
			}
			Console.WriteLine("Getting files...");
			string[] fileEntries = Directory.GetFiles(args[0]);
			Console.WriteLine("Got " + fileEntries.Length.ToString("#,##0") + " files...");
			int left = 0;
			int exceptions = 0;
			int i = 0;
			int ignored = 0;
			int ignoredHard = 0;
			int hardBounces = 0;

			Bounce b = new Bounce();
			b.UnlockComponent("DONTSTAYINBOUNCE_OS2MBg0e7GpB");

			foreach (string fileName in fileEntries)
			{
				try
				{
					b.ExamineEml(fileName);

					dealWithBounce(strings, b, fileName, ref hardBounces, ref ignoredHard, ref ignored);
				}
				catch (Exception ex)
				{
					exceptions++;
				}
				
				i++;
				if (i % 100 == 0)
					Console.WriteLine("Processed: " + i.ToString("#,##0") + " / " + fileEntries.Length.ToString("#,##0") + ", hardBounces: " + hardBounces.ToString("#,##0") + ", ignoredHard: " + ignoredHard.ToString("#,##0") + ", ignored: " + ignored.ToString("#,##0") + ", errors: " + exceptions.ToString("#,##0"));

			}
		}
Exemplo n.º 36
0
		public static void ScanGmail(string[] strings, Types type)
		{
			Console.WriteLine("VER 3");
			Bounce b = new Bounce();
			b.UnlockComponent("DONTSTAYINBOUNCE_OS2MBg0e7GpB");

			MailMan mailman = new MailMan();
			mailman.UnlockComponent("DONTSTAYINMAILQ_5CHEZpZc7Gp9");
			//mailman.ConnectTimeout = 5;
			mailman.MailPort = 995;
			mailman.PopSsl = true;
			mailman.MailHost = "pop.gmail.com";
			if (type == Types.DontStayIn)
			{
				Console.WriteLine("*****@*****.**");
				mailman.PopUsername = "******";
				mailman.PopPassword = "******";
			}
			else if (type == Types.Mixmag)
			{
				Console.WriteLine("*****@*****.**");
				mailman.PopUsername = "******";
				mailman.PopPassword = "******";
			}
			else if (type == Types.SpamTrap)
			{
				Console.WriteLine("*****@*****.**");
				mailman.PopUsername = "******";
				mailman.PopPassword = "******";
			}
			// Copy the mail into a bundle object.  The mail still remains
			// on the POP3 server.  Call TransferMail to copy and remove
			// mail from the POP3 server.
			Chilkat.EmailBundle bundle;

			Console.WriteLine("Getting bundle...");

			List<string> emailAddresses = new List<string>();
			int ignored = 0;
			int ignoredHard = 0;
			int hardBounces = 0;
			int exceptions = 0;
			int total = 0;

			// Loop over each email and save attachments.
			// Also add the email subject to a list box.

			do
			{

				emailAddresses = new List<string>();
				ignored = 0;
				ignoredHard = 0;
				hardBounces = 0;
				exceptions = 0;
				total = 0;

				bundle = mailman.CopyMail();
				Console.WriteLine("Got {0} messages", bundle.MessageCount.ToString());

				total = bundle.MessageCount;
				int i;
				for (i = 0; i < bundle.MessageCount; i++)
				{
					Chilkat.Email email = bundle.GetEmail(i);

					try
					{
						Console.Write(".");
						if (type == Types.SpamTrap)
						{
							#region spam trap
							if (email.Subject == "complaint about message from 84.45.14.32")
							{
								bool isEflyer = false;
								bool isUpdateEmail = false;
								string fullBody = email.Body;
								string recipient = "";
								string subject = "";

								//Console.WriteLine(fullBody.Length > 4096 ? fullBody.Substring(0, 4096) : fullBody);
								//Console.ReadLine();

								if (fullBody.IndexOf("From: [email protected]\r", StringComparison.OrdinalIgnoreCase) == -1)
								{
									isEflyer = true;
								}

								if (fullBody.IndexOf("Subject: DontStayIn this week", StringComparison.OrdinalIgnoreCase) > -1 ||
									fullBody.IndexOf("Subject: Don't Stay In this week", StringComparison.OrdinalIgnoreCase) > -1)
								{
									isUpdateEmail = true;
								}

								{
									string firstLine = fullBody.Substring(0, fullBody.IndexOf("\r"));
									recipient = firstLine.Substring(firstLine.IndexOf(" ") + 1);
								}

								{
									string subjectAndOn = fullBody.Substring(fullBody.IndexOf("\r\nSubject: ", StringComparison.OrdinalIgnoreCase) + 11);
									subject = subjectAndOn.Substring(0, subjectAndOn.IndexOf("\r"));
								}

								Console.WriteLine("Email: {0}, Eflyer: {1}, UpdateEmail: {2}, Subject: {3}", recipient, isEflyer, isUpdateEmail, subject.Length > 30 ? subject.Substring(0,30) : subject);

								UsrSet us = new UsrSet(new Query(new Q(Usr.Columns.Email, recipient)));
								if (us.Count > 0)
								{
									foreach (Usr u in us)
									{
										if (isEflyer)
										{
											u.SendFlyers = false;
										}
										else if (isUpdateEmail)
										{
											u.SendSpottedEmails = false;
										}
										else
										{
											u.EmailHold = true;
										}
										u.Update();
									}
								}

							}
							else
								Console.WriteLine("(not complaint email)");
							#endregion
						}
						else
						{
							b.ExamineEmail(email);
							dealWithBounce(strings, b, "", ref hardBounces, ref ignoredHard, ref ignored);
						}
						
					}
					catch (Exception ex)
					{
						Console.WriteLine("EXCEPTION");
						//Console.WriteLine(ex.Message);
						//throw ex;
						exceptions++;
					}
					//Console.WriteLine("");
					
					//if (i < 10 || i % 10 == 0)
					//	Console.WriteLine("Processed: " + i.ToString("#,##0") + " / " + total.ToString("#,##0") + ", bounces: " + hardBounces.ToString("#,##0") + ", ignored: " + ignored.ToString("#,##0") + ", ignoredHard: " + ignoredHard.ToString("#,##0") + ", errors: " + exceptions.ToString("#,##0"));


				}
			}
			while (total >= 250);
			
		}
Exemplo n.º 37
0
 // Use this for initialization
 void Start()
 {
     anim = gameObject.GetComponent<Animator>();
     bounceScript = GetComponentInChildren<Bounce>();
 }
 public void assignPickupReference(GameObject reference)
 {
     bouncePickupReference = reference.GetComponent<Bounce>();
 }
Exemplo n.º 39
0
		static void dealWithBounce(string[] strings, Bounce b, string fileName, ref int hardBounces, ref int ignoredHard, ref int ignored)
		{
			if (isUnsubscribe(b.BounceType))
			{
				Console.Write(b.BounceAddress + " ");
				SetEmailBroken(b.BounceAddress);
			}
			else if (isPossiblyHardBounce(b.BounceType))
			{
				Console.Write(b.BounceAddress + " ");

				if (isBroken(strings, b.BounceData))
				{
					Console.WriteLine("Matched HARD BOUNCE");
					incrementAndDealWith(b.BounceAddress, 1);
					hardBounces++;
				}
				else
				{
					Console.WriteLine("Unmatched HARD BOUNCE");
					incrementAndDealWith(b.BounceAddress, 2);
					ignoredHard++;
				}

				if (fileName.Length > 0)
					File.Delete(fileName);
			}
			else if (isSoftBounce(b.BounceType))
			{
				Console.WriteLine("SOFT BOUNCE");
				incrementAndDealWith(b.BounceAddress, 3);
			}
			else
			{
				//Console.WriteLine("NOT HARD BOUNCE");
				//Log1("nothardbounce", b.BounceAddress, b.BounceType, b.BounceData);
				ignored++;
			}
		}
Exemplo n.º 40
0
 // Use this for initialization
 void Start()
 {
     bounceI = GetComponent<Bounce> ();
 }
Exemplo n.º 41
0
    // Use this for initialization
    void Start()
    {
        int symbolID = 0;
        int symbolCounter = 0;
        int wordID = 0;
        int wordBump = 1;
        bool wordReset = false;
        int numberID = 0;

        bounceI = GetComponent<Bounce> ();

        //make Block 100

        for (int i=0; i < 1; i++) {
            Block newBlock = Instantiate( blockList[i] ) as Block;
            newBlock.symbol = 9;
            newBlock.word = 0;
            newBlock.number = 0;
            newBlock.transform.position = new Vector3(-10f,0f,(-10f + i));
            blockBag.Add( newBlock );
        }

        //make Blocks 1 - 99

        for (int i=1; i < blockCount; i++) {
            Block newBlock = Instantiate( blockList[i] ) as Block;

            symbolCounter++;
            if (symbolCounter > 10) {
                symbolID++;
                symbolCounter = 1;
            }

            numberID++;
            if (numberID > 9) {
                numberID = 0;
            }

            if (wordID > 9) {
                wordID = wordBump;
                wordBump++;
                wordReset = true;
            }

            newBlock.symbol = symbolID;
            newBlock.word = wordID;
            newBlock.number = numberID;
            newBlock.transform.position = new Vector3(-10f,0f,(-10f + i));
            blockBag.Add( newBlock );

            wordID++;
            if (wordReset == true) {
                wordID = 0;
                wordReset = false;
            }
        }

        Randomizer ();
        PullBlocks ();
        MakeBoard ();
    }