예제 #1
0
    /// <summary>
    /// Call back when a mole was clicked.
    /// if clicked is true. the mole was actually click and we need to add to the score.
    /// </summary>
    /// <param name="mole"></param>
    /// <param name="clicked"></param>
    private void MoleDied(Mole mole, bool clicked)
    {
        location.FreeLocation(mole);
        disabledMoles.Add(mole);
        currentMolesOnScreen--;

        if (clicked)
        {
            points += mole.data.points;
            score.UpdateScore(points);
        }

        SpawnImmediate();
    }
예제 #2
0
 // Update is called once per frame
 void Update()
 {
     if (clearMoles)
     {
         clearMoles = false;
         foreach (Mole m in moles)
         {
             m.Reset();
         }
         activeMoles.Clear();
     }
     else if (isPlaying)
     {
         float dt = Time.deltaTime;
         timePassed += dt;
         int newLevel = (int)Mathf.Floor(timePassed / 10) + 1;
         if (!isDemoMode && newLevel != level)
         {
             // Debug.Log("New Level " + newLevel);
             level = newLevel;
         }
         // level 20->60
         int promille = Mathf.Min(60, 20 + (level - 1) * 8);
         if (RandomHelper.PromilleCheck(25))
         {
             //	Debug.Log("TRY SHOW MOLE; active=" + activeMoles.Count);
             if (activeMoles.Count < 3)
             {
                 ShowMole();
             }
         }
         Mole m = null;
         for (int i = activeMoles.Count - 1; i >= 0; i--)
         {
             m = activeMoles[i];
             if (m != null && m.IsEnded())
             {
                 if (!m.WasHit && !isDemoMode)
                 {
                     onMoleMiss?.Invoke();
                 }
                 //	Debug.Log("ENDED " + m.name);
                 //m.gameObject.SetActive(false);
                 m.Reset();
                 activeMoles.RemoveAt(i);
             }
         }
     }
 }
예제 #3
0
    void ApplyRules()
    {
        GameObject[] gos;
        gos = GlobalFlock.AllMoles;

        Vector3 vCenter = Vector3.zero;
        Vector3 vAvoid  = Vector3.zero;
        float   gSpeed  = 0.1f;

        Vector3 goalPos = GlobalFlock.goalPos;

        float dist;
        int   groupSize = 0;

        foreach (GameObject go in gos)
        {
            if (go != this.gameObject)
            {
                dist = Vector3.Distance(go.transform.position, this.transform.position);
                if (dist <= neighborDistance)
                {
                    vCenter += go.transform.position;
                    groupSize++;

                    if (dist < 0.75f)
                    {
                        vAvoid = vAvoid + (this.transform.position - go.transform.position);
                    }

                    Mole anothermole = go.GetComponent <Mole>();
                    gSpeed += anothermole.speed;
                }
            }
        }

        if (groupSize > 0)
        {
            vCenter = vCenter / groupSize + (goalPos - this.transform.position);
            speed   = gSpeed / groupSize;

            Vector3 direction = (vCenter + vAvoid) - transform.position;
            if (direction != Vector3.zero)
            {
                transform.rotation = Quaternion.Slerp(transform.rotation,
                                                      Quaternion.LookRotation(direction),
                                                      TurnSpeed() * Time.deltaTime);
            }
        }
    }
예제 #4
0
        private void GameLoop_Tick(object sender, EventArgs e)
        {
            __tick_count++;

            if (_mole.IsHit && (__tick_count - __last_hit_tick) >= 10)
            {
                _mole.Dispose();
                _mole = new Mole();
            }

            _sign.Update(550, 155);
            _mole.Update(240, 250);

            Refresh();
        }
예제 #5
0
        public MoleShooter(string _userid)
        {
            InitializeComponent();
            username = _userid;

            Bitmap bmp = Resources.Crosshair;

            this.Cursor = CustomCursor.CreateCursor(bmp, bmp.Height / 2, bmp.Width / 2);

            this.mole        = new Mole(10, 200);
            this.menuBoard   = new MenuBoard(770, 30);
            this.scoreBoard  = new ScoreBoard(10, -20);
            this.bloodSplash = new BloodSplash(0, 0);
            this.random      = new Random();
        }
예제 #6
0
    void CheckExplosion(Vector3 direction)
    {
        RaycastHit hit;

        if (Physics.Raycast(transform.position, direction, out hit))
        {
            if (hit.distance <= currentWidth)
            {
                Mole hitMole = hit.transform.gameObject.GetComponent <Mole>();
                if (hitMole)
                {
                    hitMole.Die(hitMole.allowChainReaction);
                }
            }
        }
    }
    private bool CheckOverlap(Mole m, Vector2 newPos)
    {
        foreach (KeyValuePair <Mole, Vector2> entry in reservedLocation)
        {
            float minDistance = (MoleRadius * m.data.size) + (MoleRadius * entry.Key.data.size);

            float distance = Vector2.Distance(newPos, entry.Value);

            if (distance < minDistance)
            {
                return(false);
            }
        }

        return(true);
    }
예제 #8
0
        public string Inject(string SpawnTo, string FakeArgs, byte[] Shellcode)
        {
            this.Command  = SpawnTo;
            this.FakeArgs = FakeArgs;
            var pi = Sacrifice(out IntPtr readPipe);

            var mole = new Mole(pi, this.RealArgs);

            mole.SpoofArgs();

            var needle = new Needle(pi);

            needle.Inject(Shellcode);

            return(ReadFromPipe(pi, readPipe));
        }
예제 #9
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown("space"))
        {
            RaycastHit hit;

            if (Physics.Raycast(transform.position, transform.forward, out hit))
            {
                if (hit.transform.GetComponent <Mole>() != null)
                {
                    Mole mole = hit.transform.GetComponent <Mole>();
                    mole.Onhit();
                }
            }
        }
    }
예제 #10
0
 // Update is called once per frame
 void Update()
 {
     if (GvrViewer.Instance.Triggered || Input.GetKeyDown("space"))
     {
         RaycastHit hit;
         if (Physics.Raycast(transform.position, transform.forward, out hit))
         {
             if (hit.transform.GetComponent <Mole>() != null)
             {
                 Mole mole = hit.transform.GetComponent <Mole> ();
                 mole.Hide();
                 score++;
             }
         }
     }
 }
예제 #11
0
    // This function is called when the user is exiting the mole with the controller pointer
    void IsExitingMole(Collider mole)
    {
        Mole moleCollided = mole.gameObject.GetComponent <Mole>();

        if (moleCollided)
        {
            if (moleCollided.isActive)
            {
                moleCollided.addMaterials(moleCollided.currentColor);
            }
            else
            {
                moleCollided.addMaterials(null);
            }
        }
    }
예제 #12
0
    void HitLine(int position, bool expandY)
    {
        int maxValue = (expandY ? Grid.GetMaxY() : Grid.GetMaxX());

        for (int i = 1; i <= maxValue; i++)
        {
            GameObject obj = (expandY ? Grid.LookupGrid(position, i) : Grid.LookupGrid(i, position));
            if (obj)
            {
                Mole mole = obj.GetComponent <Mole>();
                if (true)
                {
                    mole.OnDeath();
                }
            }
        }
    }
예제 #13
0
 private void TapMole(Mole tappedMole)
 {
     if (tappedMole.Tapped(m_currentMole))
     {
         FindObjectOfType <SoundManager>().Play("MoleHit");
         // Show the next moles we need to
         m_currentMole += 1;
         if (m_currentMole >= m_moles.Count)
         {
             DoneGame?.Invoke(m_side, HEALTH_REWARD);
         }
         else if (m_currentMole + m_molesToPreview - 1 < m_moles.Count)
         {
             m_moles[m_moleOrder[m_currentMole + m_molesToPreview - 1]].SetSpritePopped();
         }
     }
 }
예제 #14
0
 void HitWithinRange()
 {
     for (int x = posX - radius; x <= posX + radius; x++)
     {
         for (int y = posY - radius; y <= posY + radius; y++)
         {
             GameObject obj = Grid.LookupGrid(x, y);
             if (obj)
             {
                 Mole mole = obj.GetComponent <Mole>();
                 if (true)
                 {
                     mole.OnDeath();
                 }
             }
         }
     }
 }
    public Vector2 FindLocation(Mole m)
    {
        Vector2 random = GetRandom();

        // number of attempt to find a non-overlaping location
        int numOfAttempts = 0;

        // if number of attempts reaches 25, just return an overlaping location this time.
        while (CheckOverlap(m, random) == false && numOfAttempts < 25)
        {
            random = GetRandom();
            numOfAttempts++;
        }

        //Debug.Log(numOfAttempts);
        reservedLocation.Add(m, random);
        return(random);
    }
    void FlyArm(Mole mole)
    {
        LeanTween.cancel(metteArm.gameObject);
        metteArm.gameObject.SetActive(true);
        Vector3 mp = mole.transform.position;
        //metteArm.localRotation = Quaternion.Euler(0f,0f,105f);
        //metteArm.position = new Vector3(-1 * mp.x + 3.3f, -1 * mp.y + 5.7f, -1* mp.z - 0.2f);
        // Debug.Log("POS " + mp);
        Vector3 newPos = new Vector3(mp.x + armX, mp.y + armY, mp.z + armZ);

        //metteArm.position = newPos;
        LeanTween.rotateLocal(metteArm.gameObject, new Vector3(0f, 0f, 105f), 0.2f);
        LTDescr tween = LeanTween.move(metteArm.gameObject, newPos, 0.2f);

        metteFull.SetActive(false);
        metteNoArm.SetActive(true);
        tween.setOnComplete(FlyArmHome);
    }
예제 #17
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetMouseButtonDown(0) || Input.GetKeyDown("space"))
     {
         RaycastHit hit;
         if (Physics.Raycast(transform.position, transform.forward, out hit))
         {
             if (hit.transform.GetComponent <Mole>() != null)
             {
                 Debug.Log("I've hit a mole!");
                 score++;
                 Mole mole = hit.transform.GetComponent <Mole>();
                 mole.OnHit();
                 pokeball.Hit(mole.transform.position);
             }
         }
     }
 }
예제 #18
0
        /// <summary>
        /// A client has reported that they've acquired a kill
        /// The whole game itself is a race condition, and the clients report their own name so cheating could be easily accomplished.
        /// In theory the connections could be tracked on the server instead but...
        /// </summary>
        /// <param name="me"></param>
        public void Kill(string me)
        {
            //update the score for the person that killed this mole
            ScoreTracker.AddKillFor(me);

            //generate the next mole
            var newMole = Mole.GetRandomMole();

            //the delay that clients will expeirience prior to the next mole gneeration
            var delay = new Random().Next(1000, 5000);

            //first to send this message wins, so send them the response
            Clients.Others.Whack(String.Format("You missed! {0} killed him!", me), delay, newMole.Location.X, newMole.Location.Y, newMole.Size);
            Clients.Caller.Whack("You killed him!", delay, newMole.Location.X, newMole.Location.Y, newMole.Size);

            //push a message out to the clients to update the scores
            Clients.All.UpdateScoreDisplay(JsonConvert.SerializeObject(ScoreTracker.Score));
        }
예제 #19
0
 void HitWithinRange(GridSpawner gridSpawner)
 {
     for (int x = posX - radius; x <= posX + radius; x++)
     {
         for (int y = posY - radius; y <= posY + radius; y++)
         {
             GameObject obj = gridSpawner.LookupGrid(x, y);
             if (obj)
             {
                 Mole mole = obj.GetComponent <Mole>();
                 if (true)
                 {
                     mole.Die();
                 }
             }
         }
     }
 }
예제 #20
0
        public void SelectHolesToSpawn()
        {
            int lastIndex = -1;

            for (int n = 0; n < gm.phases[gm.currentPhase].activeMolesCount; n++)
            {
                int holeIndex;
                do
                {
                    holeIndex = Random.Range(0, holes.Count);
                } while (lastIndex == holeIndex);

                lastIndex = holeIndex;
                activeHoles.Add(holes[holeIndex]);

                Mole moleToSpawn = holes[holeIndex].GetMoleToSpawn();
                moleToSpawn.ShowMole();
            }
        }
    void Update()
    {
        if (GvrPointerInputModule.Pointer.TriggerDown)
        {
            RaycastHit hit;

            if (Physics.Raycast(transform.position, transform.forward, out hit))
            {
                if (hit.transform.GetComponent <Mole> () != null)
                {
                    Mole mole = hit.transform.GetComponent <Mole> ();
                    mole.OnHit();
                    hammer.Hit(mole.transform.position);

                    score++;
                }
            }
        }
    }
예제 #22
0
    public Mole GetNearestMoleOnSurface(Vector3 position)
    {
        float distance = float.PositiveInfinity, currentDistance;
        Mole  result = null;

        for (int i = 0; i < moles.Count; ++i)
        {
            if (!moles[i].IsUnderGround)
            {
                currentDistance = Vector3.Distance(position, moles[i].transform.position);
                if (currentDistance < distance)
                {
                    result   = moles[i];
                    distance = currentDistance;
                }
            }
        }
        return(result);
    }
예제 #23
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetButtonDown("Fire1") || Input.GetKeyDown("space"))
        {
            RaycastHit hit;

            if (Physics.Raycast(transform.position, transform.forward, out hit))
            {
                if (hit.transform.GetComponent <Mole>() != null)
                {
                    Mole mole = hit.transform.GetComponent <Mole>();
                    mole.OnHit();
                    hammer.Hit(mole.transform.position);

                    score++;
                }
            }
        }
    }
예제 #24
0
 void CheckForMoleHit()
 {
     if (Input.GetMouseButtonDown(0))
     {
         Mole mole = MoleUnderMouse();
         if (mole != null)
         {
             Debug.Log("Hit!");
             roundActive = false;
             if (mole.Letter == currentLetter)
             {
                 mole.Hit();
             }
             else
             {
                 mole.Miss();
             }
         }
     }
 }
예제 #25
0
    IEnumerator CreateMole()
    {
        int x, y;

        yield return(new WaitForSeconds(Random.Range(1 - difficulty, 2 - difficulty)));

        while (curHealth.health > 0)
        {
            x = Random.Range(0, cells.GetLength(0));
            y = Random.Range(0, cells.GetLength(1));

            if (!cells[x, y].GetComponentInChildren <Mole>() && !cells[x, y].GetComponentInChildren <Heart>())
            {
                Mole mMole = Instantiate(mole, cells[x, y].GetComponentInChildren <SpawnPosition>().transform.position, Quaternion.identity);
                mMole.transform.SetParent(cells[x, y].transform);
            }

            yield return(new WaitForSeconds(Random.Range(1 - difficulty, 2 - difficulty)));
        }
    }
예제 #26
0
    void MoleUpdate(Mole m, float time)
    {
        m.animationTime += time;
        switch (m.moleMode)
        {
        case Mole.Mole_CurrentMode.RAISED:
            if (!IsCompleted && m.animationTime >= holdTime)
            {
                m.moleMode      = Mole.Mole_CurrentMode.LOWERING;
                m.animationTime = 0f;
            }
            break;

        case Mole.Mole_CurrentMode.RAISING:
            float yPos = Mathf.Lerp(-5f, 5f, raisingMotion.Evaluate(m.animationTime / raiseTime));
            m.mole.localPosition = new Vector3(m.mole.localPosition.x, yPos, m.mole.localPosition.z);
            if (m.animationTime >= raiseTime)
            {
                m.moleMode      = Mole.Mole_CurrentMode.RAISED;
                m.animationTime = 0f;
            }
            break;

        case Mole.Mole_CurrentMode.LOWERED:
            //do nothing
            break;

        case Mole.Mole_CurrentMode.LOWERING:
            yPos = Mathf.Lerp(5f, -5f, raisingMotion.Evaluate(m.animationTime / lowerTime));
            m.mole.localPosition = new Vector3(m.mole.localPosition.x, yPos, m.mole.localPosition.z);
            if (m.animationTime >= lowerTime)
            {
                m.moleMode      = Mole.Mole_CurrentMode.LOWERED;
                m.animationTime = 0f;
                //m.mole.GetComponent<MeshRenderer>().material = NeutralMaterial;
                m.mole.GetComponent <MeshRenderer>().material.color = Color.Lerp(weakColor, strongColor, molesHit / (float)molesToWin);
                m.struck = false;
            }
            break;
        }
    }
예제 #27
0
    // Update is called once per frame
    void Update()
    {
        if (GvrViewer.Instance.Triggered || Input.GetKeyDown("space"))
        {
            // GvrViewerMain will be replaced by GvrEditorEmulator in newest version of VR SDK
            // GvrViewer is unknown in new versions of the VR SDK
            RaycastHit hit;

            if (Physics.Raycast(transform.position, transform.forward, out hit))
            {
                // print the name of the avocado we hit
                if (hit.transform.GetComponent <Mole>() != null)
                {
                    Mole mole = hit.transform.GetComponent <Mole> ();
                    mole.OnHit();
                    hammer.Hit(mole.transform.position);
                    score++;
                }
            }
        }
    }
예제 #28
0
    private void OnMoleKilled(Mole mole)
    {
        if (mole.TryGetComponent(out GoldMole goldMole))
        {
            _currentScore += 5;
        }
        else
        {
            _currentScore++;
        }

        if (_hightScore <= _currentScore)
        {
            _hightScore = _currentScore;
            Saver.SaveScore("Score", _hightScore);
            HightScoreChanged?.Invoke(_hightScore);
        }

        _scoreText.text      = "Текущий счёт: " + _currentScore.ToString();
        _hightScoreText.text = "Рекорд: " + _hightScore.ToString();
    }
예제 #29
0
    // This function will be called when the user is pressing the trigger on a mole only
    void MoleWhackDetection(Collider mole)
    {
        Mole moleCollided = mole.gameObject.GetComponent <Mole>();

        if (moleCollided)
        {
            moleCollided.isActive = false;

            if (moleCollided.currentColor == "green")    //We add a point if the whacked mole is green
            {
                wallCtrl.totalMolesWhacked++;
            }
            else if (moleCollided.currentColor == "red") //We add a missed point if the whacked mole is red
            {
                wallCtrl.redWhacked++;
            }

            moleCollided.addMaterials(null);
            moleCollided.startShining = true;
        }
    }
예제 #30
0
 /*################################################################################
 *   Functions: private
 ################################################################################*/
 /*--------------------------------------------------------------------------------
 *   TouchRaycastMole
 *  --------------------------------------------------------------------------------*/
 /// <summary>
 /// Touch raycast mole, trigger event whenever a mole is hit.
 /// </summary>
 private void TouchRaycastMole()
 {
     if (Input.touchCount > 0)
     {
         foreach (Touch touch in Input.touches)
         {
             if (touch.phase == TouchPhase.Began)
             {
                 Ray        ray = camera.ScreenPointToRay(touch.position);
                 RaycastHit hit;
                 if (Physics.Raycast(ray, out hit))
                 {
                     Mole mole = hit.collider.GetComponent <Mole>();
                     if (mole != null)
                     {
                         OnHit?.Invoke(mole);
                     }
                 }
             }
         }
     }
 }