示例#1
0
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    IEnumerator StartLoader()
    {
        //yield return new WaitForSeconds(2);
        while (LevelManager.instance.totalNumberOfRowsLeft > 0)
        {
            yield return(null);
        }
        isSwap = false;
        thresoldLineTransform = GameObject.Find("Thresold Line").transform;
        striker       = GameObject.Find("Striker");
        strikerScript = striker.GetComponent <Striker>();

        currentStrikerPosition = GameObject.Find("Current Striker Position").transform;
        nextStrikerPosition    = GameObject.Find("Next Striker Position").transform;

        InGameScriptRefrences.playingObjectManager.ResetAllObjects();
        InGameScriptRefrences.playingObjectManager.GetMissionCountTotal();
        GenerateNextStriker();
        UpdateThresoldPosition();
        GenerateStriker();
        bStartDone = true;

        if (TutorialManager.instance != null)
        {
            yield return(new WaitForSeconds(0.5f));

            while (iTween.tweens.Count > 0)
            {
                yield return(null);
            }
            TutorialManager.instance.ShowTutorial();
        }
    }
示例#2
0
    private Vector2 GetOverlapPositionForStriker(Striker striker, CollisionSide colSide, RaycastHit2D rayHit, Vector2 actualPos, float radius)
    {
        Vector2 startPos           = actualPos;
        Vector2 newDirectionVector = new Vector2();

        switch (colSide)
        {
        case CollisionSide.Bottom:
            newDirectionVector = striker.transform.up;
            break;

        case CollisionSide.Top:
            newDirectionVector = striker.transform.up * -1;
            break;

        case CollisionSide.Left:
            newDirectionVector = striker.transform.right;
            break;

        case CollisionSide.Right:
            newDirectionVector = striker.transform.right * -1;
            break;
        }

        BoxCollider2D boxCollider = rayHit.collider as BoxCollider2D;
        float         fromCenterToBorderHorizontally = boxCollider.size.x * boxCollider.transform.localScale.x / 2;
        float         fromCenterToBorderVertically   = boxCollider.size.y * boxCollider.transform.localScale.y / 2;

        Vector2 a          = (Vector2)boxCollider.bounds.center + fromCenterToBorderHorizontally * (Vector2)striker.transform.right * -1;
        Vector2 b          = (Vector2)boxCollider.bounds.center + fromCenterToBorderHorizontally * (Vector2)striker.transform.right;
        Vector2 c          = (Vector2)boxCollider.bounds.center + fromCenterToBorderVertically * (Vector2)striker.transform.up;
        Vector2 d          = (Vector2)boxCollider.bounds.center + fromCenterToBorderVertically * (Vector2)striker.transform.up * -1;
        Vector2 e          = new Vector2();
        Vector2 f          = new Vector2();
        float   distToMove = 0;

        switch (colSide)
        {
        case CollisionSide.Bottom:
        case CollisionSide.Top:
            e          = actualPos + newDirectionVector * 10;
            f          = actualPos - newDirectionVector * 10;
            actualPos  = Math2D.GetIntersectionPointCoordinates(a, b, e, f);
            distToMove = radius + fromCenterToBorderVertically + distToMoveOnOverlap;
            break;

        case CollisionSide.Left:
        case CollisionSide.Right:
            e          = actualPos + newDirectionVector * 10;
            f          = actualPos - newDirectionVector * 10;
            actualPos  = Math2D.GetIntersectionPointCoordinates(c, d, e, f);
            distToMove = radius + fromCenterToBorderHorizontally + distToMoveOnOverlap;
            break;
        }
        Vector2 newPos = actualPos + newDirectionVector * distToMove;

        Debug.DrawLine(startPos, newPos, Color.white, 4);
        return(newPos);
    }
示例#3
0
        public void Move()
        {
            var striker = new Striker(new MockBoard(), new MockConsoleWriter(), 3);

            striker.MoveLeft();

            Assert.Equal(1, striker.GetMovesTaken());
        }
示例#4
0
        private float _minSquaredDistanceToTarget; // avoid usage of Sqrt

        public override void Initialize(Striker stateMachine)
        {
            base.Initialize(stateMachine);

            _target       = Striker.Target;
            _navMeshAgent = Striker.NavMeshAgent;

            _minSquaredDistanceToTarget = minDistanceToTarget * minDistanceToTarget;
        }
示例#5
0
        public void ReduceLives()
        {
            int initialLives = 3, livesToDecrement = 1;

            var striker = new Striker(new MockBoard(), new MockConsoleWriter(), initialLives);

            striker.ReduceLives(livesToDecrement);

            Assert.Equal(initialLives - livesToDecrement, striker.GetLivesLeft());
        }
示例#6
0
文件: Slimer.cs 项目: MyEyes/Igorr
 public Slimer(IMap map, string charfile, Rectangle spawnRect, int id)
     : base(map, charfile, spawnRect, id)
 {
     GivePart(new Legs().GetID());
     Body.BodyPart part = new Striker();
     GivePart(part.GetID());
     _groupID = 5;
     _XPBonus = 25;
     followRect = new Rectangle(spawnRect.X - 80, spawnRect.Y - 16, 160, 32);
     spawnPoint = new Point(spawnRect.X + spawnRect.Width / 2, spawnRect.Y + spawnRect.Height / 2);
     _objectType = 5000;
 }
示例#7
0
文件: Slimer.cs 项目: MyEyes/Igorr
        public Slimer(IMap map,Rectangle spawnRect, int id)
            : base(map,spawnRect, id)
        {
            _XPBonus = 25;
            GivePart(new Legs().GetID());
            Logic.Body.AttackPart part = new Striker();
            GivePart(part.GetID());
            EquipAttack(0, part);
            _groupID = 5;

            followRect = new Rectangle(spawnRect.X - 80, spawnRect.Y - 16, 160, 32);
            spawnPoint = new Point(spawnRect.X + spawnRect.Width / 2, spawnRect.Y + spawnRect.Height / 2);
            _objectType = 5000;
        }
示例#8
0
        public void CheckIfAlive()
        {
            int initialLives = 3;

            var striker = new Striker(new MockBoard(), new MockConsoleWriter(), initialLives);

            striker.ReduceLives(1);

            Assert.True(striker.Alive());

            striker.ReduceLives(initialLives - 1);

            Assert.False(striker.Alive());
        }
示例#9
0
        public void Reset()
        {
            int maximumLives = 3, livesToDecrement = 1;
            var striker = new Striker(new MockBoard(), new MockConsoleWriter());

            striker.ReduceLives(livesToDecrement);
            striker.MoveRight();

            Assert.NotEqual(maximumLives, striker.GetLivesLeft());
            Assert.NotEqual(0, striker.GetMovesTaken());

            striker.Reset();

            Assert.Equal(maximumLives, striker.GetLivesLeft());
            Assert.Equal(0, striker.GetMovesTaken());
        }
示例#10
0
        public static List <Striker> GenerateStrikers(int numberOFPlayers)
        {
            int            i           = 0;
            List <Striker> listStriker = new List <Striker>(numberOFPlayers);

            while (i < numberOFPlayers)
            {
                var     random           = new Random();
                int     indexOfFirstName = random.Next(Constants.FIRST_NAMES.Length);
                int     indexOfLastName  = random.Next(Constants.FIRST_NAMES.Length);
                Striker newStriker       = new Striker(Constants.FIRST_NAMES[indexOfFirstName], Constants.LAST_NAMES[indexOfLastName], random.Next(Constants.MIN_PLAYER_AGE, Constants.MAX_PLAYER_AGE), random.Next(Constants.MIN_PLAYER_COMPOSURE, Constants.MAX_PLAYER_COMPOSURE), random.Next(Constants.MIN_PLAYER_WORK_RATE, Constants.MAX_PLAYER_COMPOSURE), random.Next(Constants.MIN_STRIKER_ACCURACY, Constants.MAX_STRIKER_ACCURACY), "");
                listStriker.Add(newStriker);
                i++;
            }
            return(listStriker);
        }
示例#11
0
        public void UpdateCurrentOverShouldSetOver()
        {
            //Act
            this._inning.UpdateCurrentOver(this._bowler, this._striker, this._nonStriker);

            //Assert
            this._inning.CurrentOver !.Bowler
            .Should()
            .Be(this._bowler);

            this._inning.CurrentOver !.Striker
            .Should()
            .Be(this._striker);

            this._inning.CurrentOver !.NonStriker
            .Should()
            .Be(this._nonStriker);
        }
示例#12
0
    private Vector2 GetNewPositionWhenOverlaping(CollisionType colType, CollisionSide colSide, ICollider collidingObject, RaycastHit2D rayHit, Vector2 actualPos, float radius)
    {
        switch (colType)
        {
        case CollisionType.Frame:
            return(GetOverlapPositionForFrame(colSide, rayHit, actualPos, radius));

        case CollisionType.Ship:
        case CollisionType.Enemy:
            return(GetOverlapPositionForEnemyOrShip(colSide, rayHit, actualPos, radius));

        case CollisionType.StrikerLeft:
        case CollisionType.StrikerRight:
            Striker striker = collidingObject as Striker;
            return(GetOverlapPositionForStriker(striker, colSide, rayHit, actualPos, radius));

        default:
            return(actualPos);
        }
    }
示例#13
0
    private void TryUseStriker(GamePad.Trigger trigger, Striker striker, ref bool triggerState)
    {
        float axis = GamePad.GetTrigger(trigger, PlayerShip.PlayerInfo.GamepadIndex);

        if (!triggerState)
        {
            if (axis >= gamepadTriggerSensitivity)
            {
                triggerState = true;
                striker.MoveBlade();
            }
        }
        else
        {
            if (axis < gamepadTriggerSensitivity)
            {
                triggerState = false;
                striker.StopBlade();
            }
        }
    }
示例#14
0
        static void Main(string[] args)
        {
            const int playtime = 180;

            Player p1 = new Striker("Jugador1", 200, 12, 3);

            GetRank(p1, playtime);

            Player p2 = new Striker("Jugador2", 300, 10, 10);

            GetRank(p2, playtime);

            Player p3 = new Goalkeeper("Portero1", 300, 5, 8);

            GetRank(p3, playtime);

            Player p4 = new Goalkeeper("Portero2", 400, 11, 6);

            GetRank(p4, playtime);

            Console.ReadKey();
        }
示例#15
0
    private Vector2 SetVelocityBasedOnCollisionType(CollisionType colType, CollisionSide colSide, ICollider collidingObject, float endSpeed, Vector2 actualVelocity)
    {
        switch (colType)
        {
        case CollisionType.Frame:
        case CollisionType.Enemy:
            return(SetVelocity(colSide, endSpeed, LastFrameVelocity));

        case CollisionType.Ship:
            return(SetVelocity(colSide, endSpeed, actualVelocity));

        case CollisionType.StrikerLeft:
        case CollisionType.StrikerRight:
            Striker striker = collidingObject as Striker;
            Vector2 vel     = striker.GetForceOnBallHit(this, colSide);
            Rigidbody.velocity = vel;
            return(vel);

        default:
            return(Vector2.zero);
        }
    }
示例#16
0
 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 void Awake()
 {
     instance = this;
 }
示例#17
0
    void Update()
    {
        playerController.Run();
        if (delay <= 0) {
            if (rowNum < levelRows.Length) {
                string levelRow = levelRows[rowNum];
                rowNum++;
                string[] enemyIds = levelRow.Split(',');
                for (int i = 0; i < enemyIds.Length; i++) {
                    DbItem enemyItem = null;
                    EnemyBehaviour enemy = null;
                    string enemyId = enemyIds[i];
                    string movementId = null;
                    if (enemyIds[i].Contains(":")) {
                        enemyId = enemyIds[i].Split(':')[0];
                        movementId = enemyIds[i].Split(':')[1];
                        //enemyId = enemyIds[i].Substring(0, enemyIds[i].IndexOf(':'));
                        //movementId = enemyIds[i].Substring(enemyIds[i].IndexOf(':') + 1);
                    }
                    switch (enemyId) {
                        case "0":
                            break;
                        case "1": {
                                enemyItem = ItemDatabase.GetItemByFileId("0");
                                enemy = new Blinky();
                                enemy.SetHealth(3);
                                break;
                            }
                        case "2": {
                                enemyItem = ItemDatabase.GetItemByFileId("1");
                                enemy = new Skrull();
                                enemy.SetHealth(5);
                                break;
                            }
                        case "3": {
                                enemyItem = ItemDatabase.GetItemByFileId("2");
                                enemy = new RedReaper();
                                enemy.SetHealth(5);
                                break;
                            }
                        case "4": {
                                enemyItem = ItemDatabase.GetItemByFileId("6");
                                enemy = new Striker();
                                enemy.SetHealth(8);
                                enemy.SetExplosionFX(ItemDatabase.GetItemByName("ExplosionOrange").gameModel);
                                break;
                            }
                        default:
                            Debug.Log("Unknown Item ID: " + enemyIds[i]);
                            break;
                    }
                    if (enemy != null && enemyItem != null) {
                        enemy.SetModel((GameObject)GameObject.Instantiate(enemyItem.gameModel, new Vector3((screenWidth * (float)i) / 8f - screenWidth / 2f + screenWidth / 16f, screenHeight + 2f), enemyItem.gameModel.transform.rotation));
                        enemy.GetModel().GetComponent<CollisionController>().SetObject(enemy);
                        //print("EnemyObject: " + enemy);
                        if (movementId != null) {
                            //print("MoveId: " + movementId);
                            EnemyMovement movement = null;
                            switch (movementId) {
                                case "0":
                                    break;
                                case "1":
                                    {
                                        movement = new MoveDown();
                                        movement.SetEnemy(enemy.GetModel());
                                        //enemy.SetMovement(movement);
                                        //enemyObject.AddComponent<MoveDown>();
                                        break;
                                    }
                                case "2":
                                    {
                                        //MoveRightAngle moveRightAngle = new MoveRightAngle();
                                        movement = new MoveRightAngle();
                                        movement.SetEnemy(enemy.GetModel());
                                        //moveRightAngle.SetScreenDimensions(GetScreenWidth(), GetScreenHeight());
                                        //movement = moveRightAngle;
                                        //enemy.SetMovement(movement);
                                        //enemyObject.AddComponent<MoveRightAngle>();
                                        break;
                                    }
                                case "3":
                                    {
                                        movement = new MoveLeftAngle();
                                        movement.SetEnemy(enemy.GetModel());

                                        //MoveLeftAngle moveLeftAngle = new MoveLeftAngle();
                                        //EnemyMovement movement = moveLeftAngle;
                                        //movement.SetEnemy(enemy.GetModel());
                                        //moveLeftAngle.SetScreenDimensions(GetScreenWidth(), GetScreenHeight());
                                        //movement = moveLeftAngle;
                                        //enemy.SetMovement(movement);

                                        //enemyObject.AddComponent<MoveLeftAngle>();
                                        break;
                                    }
                                default:
                                    Debug.Log("Unkown Movement ID: " + movementId);
                                    break;
                            }
                            if (movement is ScreenAware) {
                                ((ScreenAware)movement).SetScreenDimensions(GetScreenWidth(), GetScreenHeight());
                            }
                            enemy.SetMovement(movement);
                        }
                    }
                    if (enemy != null) {
                        //GameObject enemyModel = enemyItem.gameModel;
                        //GameObject enemyObject = Instantiate(enemyModel, new Vector3((screenWidth * (float)i) / 8f - screenWidth / 2f + screenWidth / 16f, screenHeight + 2f), enemyModel.transform.rotation) as GameObject;

                        //enemyObject = Instantiate(enemyModel, new Vector3((screenWidth * (float)i) / 8f - screenWidth / 2f + screenWidth / 16f, screenHeight + 2f), enemyModel.transform.rotation) as GameObject;
                        //enemyObject.GetComponent<EnemyBehaviour>().SetHealth(enemyItem.health);
                        //enemyObject.GetComponent<EnemyBehaviour>().SetMovement(movement);

                        //enemyObject.AddComponent<MoveDown>();

                        //spawnedObjects.Add(enemy);
                        GarbageCollector.AddGameObject(enemy);
                    }
                }
            }
            delay = spawnDelay * Time.deltaTime;
        } else {
            delay -= Time.deltaTime;
        }

        //List<EnemyBehaviour> markedObjects = new List<EnemyBehaviour>();
        List<ObjectModel> om = GarbageCollector.GetObjects();
        foreach (ObjectModel o in om) {
            if (o is EnemyBehaviour) {
                ((EnemyBehaviour)o).Move(2.5f);
            }
        }
        List<GameObject> markedItems = new List<GameObject>();
        foreach (KeyValuePair<GameObject, Vector3> item in SpawnItem.GetItems()) {
            GameObject spawnedItem = (GameObject)Instantiate(item.Key, item.Value, Quaternion.identity);
            markedItems.Add(item.Key);
        }
        foreach (GameObject g in markedItems) {
            SpawnItem.RemoveItem(g);
        }

        GarbageCollector.Clean();
    }
示例#18
0
    public List <IRayCollider> HandleCollision(List <IRayCollider> collidersToSkip)
    {
        if (skipOneFrameFromCollisionSystem)
        {
            return(new List <IRayCollider>());
        }
        List <IRayCollider> collidedWith = new List <IRayCollider>();

        Vector2 direction      = currentCenterPoint - LastFrameCenterPoint;
        float   distanceForRay = direction.magnitude;
        float   radius         = Collider.radius / 2;

        int safe = 0;

        while (rayHits.Length > 0 && distanceForRay > 0)
        {
            rayHits.SortByLength();
            if (rayHits.Length > 1)
            {
                for (int i = 0; i < rayHits.Length; i++)
                {
                    //Debug.LogWarningFormat("[{0}] point: {1} centroid: {2} length: {3}", i, rayHits[i].point, rayHits[i].centroid, rayHits[i].distance);
                }
            }
            RaycastHit2D  rayHit  = rayHits[0];
            CollisionSide colSide = CollisionSide.Bottom;
            if (rayHit.collider.CompareTag(GameTags.Frame))
            {
                FrameCollider frameCollider = rayHit.collider.GetComponent <FrameCollider>();
                IRayCollider  col           = frameCollider as IRayCollider;
                if (!collidersToSkip.Contains(col))
                {
                    if (frameCollider.DestroyBallAndProjectiles)
                    {
                        GameController.Instance.RemoveBallFromPlay(this);
                    }
                    else
                    {
                        colSide = frameCollider.CollisionSide;
                        OnCollision(this, rayHit, colSide, CollisionType.Frame, defaultToTotalDistance, LastFrameVelocity.magnitude, safe, frameCollider, out distanceForRay);
                    }

                    if (!collidedWith.Contains(col))
                    {
                        collidedWith.Add(col);
                    }
                }
            }
            else if (rayHit.collider.CompareTag(GameTags.Enemy))
            {
                // Debug.DrawLine(currentCenterPoint, LastFrameCenterPoint, Color.green, 2);
                EnemyBase    enemy = rayHit.collider.GetComponent <EnemyBase>();
                IRayCollider col   = enemy as IRayCollider;

                if (!collidersToSkip.Contains(col))
                {
                    colSide = CollisionSideDetect.GetCollisionSide(rayHit.centroid, rayHit.point);
                    OnCollision(this, rayHit, colSide, CollisionType.Enemy, defaultToTotalDistance, PhysicsConstants.BallSpeedAfterEnemyHit, safe, enemy, out distanceForRay);
                    enemy.OnCollisionWithBall(this);
                    if (!collidedWith.Contains(col))
                    {
                        collidedWith.Add(col);
                    }
                }
            }
            else if (rayHit.collider.CompareTag(GameTags.Ship))
            {
                ShipCollider ship = rayHit.collider.GetComponent <ShipCollider>();
                IRayCollider col  = ship as IRayCollider;
                if (!collidersToSkip.Contains(col))
                {
                    colSide = ship.GetCollisionSideWithBall(this, LastFrameCenterPoint);
                    OnCollision(this, rayHit, colSide, CollisionType.Ship, defaultToTotalDistance, PhysicsConstants.BallSpeedAfterShipHit, safe, ship, out distanceForRay);
                }

                if (!collidedWith.Contains(col))
                {
                    collidedWith.Add(col);
                }
            }
            else if (rayHit.collider.CompareTag(GameTags.Striker))
            {
                Striker      striker = rayHit.collider.GetComponent <Striker>();
                IRayCollider col     = striker as IRayCollider;
                if (!collidersToSkip.Contains(col))
                {
                    colSide = striker.GetCollisionSideWithBall(LastFrameCenterPoint);
                    OnCollision(this, rayHit, colSide, striker.CollisionType, defaultToTotalDistance, striker.GetForceOnBallHit(this, colSide).magnitude, safe, striker, out distanceForRay);
                }

                if (!collidedWith.Contains(col))
                {
                    collidedWith.Add(col);
                }
            }

            //Debug.LogFormat("{0} collision with {1} on side {2}", safe, rayHit.collider.gameObject.name, colSide);

            safe++;
        }

        return(collidedWith);
    }
示例#19
0
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    IEnumerator StartLoader()
    {
        //yield return new WaitForSeconds(2);
        while(LevelManager.instance.totalNumberOfRowsLeft > 0){
            yield return null;
        }
        isSwap = false;
        thresoldLineTransform = GameObject.Find("Thresold Line").transform;
        striker = GameObject.Find("Striker");
        strikerScript = striker.GetComponent<Striker>();

        currentStrikerPosition = GameObject.Find("Current Striker Position").transform;
        nextStrikerPosition = GameObject.Find("Next Striker Position").transform;

        InGameScriptRefrences.playingObjectManager.ResetAllObjects();
        InGameScriptRefrences.playingObjectManager.GetMissionCountTotal();
        GenerateNextStriker();
        UpdateThresoldPosition();
        GenerateStriker();
        bStartDone=true;

        if(TutorialManager.instance!=null){
            yield return new WaitForSeconds(0.5f);
            while(iTween.tweens.Count>0){
                yield return null;
            }
            TutorialManager.instance.ShowTutorial();
        }
    }
示例#20
0
        // false = no goal, true = goal
        public static bool CalculateShotIsGoal(string ShotDirection, string GoalkeeperDirection, Goalkeeper gk, Striker st)
        {
            Random rand = new Random();
            int    AccuracyAndComposure = (st.GetStrikerAccuracy() * st.GetPlayerComposure()) / (10 * (Constants.MAX_PLAYER_COMPOSURE - st.GetPlayerComposure()));

            if (rand.Next(1, 20) > AccuracyAndComposure)
            {
                Console.WriteLine("Striker missed.");
                return(false);
            }
            else if ((GoalkeeperDirection == ShotDirection) && (rand.Next(1, 10) < (gk.GetGoalkeeperSkill() / 10)))
            {
                Console.WriteLine("The goalkeeper saved.");
                return(false);
            }
            return(true);
        }
示例#21
0
    private Vector2 GetPositionOnStrikerHit(CollisionSide colSide, ICollider collidingObject, Vector2 centroidPoint, Vector2 velocity, float distanceAfterHit)
    {
        Striker striker = collidingObject as Striker;

        return(centroidPoint + striker.GetForceOnBallHit(this, colSide).normalized *distanceAfterHit);
    }
示例#22
0
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    void Awake()
    {
        instance = this;
    }