Ejemplo n.º 1
0
        void ProcessCommandBuy(ref State state, Player player, Turn.Command command, bool reflected)
        {
            Unit temp = null;
            int  type = command.arguments[0];
            int  line = command.arguments[1];

            if (line < 0 || line >= Const.NumberOfLines)
            {
                command.comment = "Неверно указана горизонталь";
                return;
            }
            int bas         = reflected ? Const.NumberOfColumns + 1 : 0;
            int destination = reflected ? (Const.NumberOfColumns + 1 - command.arguments[2]) : command.arguments[2];

            if (destination < 1 || destination > Const.NumberOfColumns)
            {
                command.comment = "Неверно указано место назначения";
                return;
            }
            OwnerType owner = player.Owner;

            switch (type)
            {
            case (int)UnitTypes.Armored:
                temp = new Armored(owner, line, bas, destination);
                break;

            case (int)UnitTypes.Cannon:
                temp = new Cannon(owner, line, bas, destination);
                break;

            case (int)UnitTypes.Combine:
                temp = new Combine(owner, line, bas, destination);
                break;

            case (int)UnitTypes.Mine:
                temp = new Mine(owner, line, bas, destination);
                break;

            case (int)UnitTypes.Tank:
                temp = new Tank(owner, line, bas, destination);
                break;

            default:
                command.comment = "Неверный тип юнита";
                return;
            }
            if (player.Money < temp.Cost)
            {
                command.comment = "Недостаточно денег";
                return;
            }
            if (player.Units[line] != null)
            {
                command.comment = "Горизонталь занята";
                return;
            }
            player.Money -= temp.Cost;
            state.AddUnit(bas, line, player, temp);
        }
Ejemplo n.º 2
0
        Unit CreateUnit(int type)
        {
            Unit temp = null;

            switch (type)
            {
            case (int)UnitTypes.Armored:
                temp = new Armored(OwnerType.Player1, 0, 0, 0);
                break;

            case (int)UnitTypes.Cannon:
                temp = new Cannon(OwnerType.Player1, 0, 0, 0);
                break;

            case (int)UnitTypes.Combine:
                temp = new Combine(OwnerType.Player1, 0, 0, 0);
                break;

            case (int)UnitTypes.Mine:
                temp = new Mine(OwnerType.Player1, 0, 0, 0);
                break;

            case (int)UnitTypes.Tank:
                temp = new Tank(OwnerType.Player1, 0, 0, 0);
                break;
            }
            return(temp);
        }
Ejemplo n.º 3
0
        public override string ToString()
        {
            return(string.Format(
                       "Информация о персонаже: \n" +
                       "Имя: {0} \n" +
                       "ID: {1} \n" +
                       "Состояние: {2} \n" +
                       "Cпособен двигаться: {3} \n" +
                       "Способен говорить: {4} \n" +
                       "Раса: {5} \n" +
                       "Пол: {6} \n" +
                       "Возраст: {7} \n" +
                       "Здоровье: {8}/{9} \n" +
                       "Опыт: {10} \n" +
                       "Броня: {11} \n",
                       Name,
                       ID.ToString(),
                       Condition.ToString(),
                       AbleToSpeak.ToString(),
                       AbleToMove.ToString(),
                       Race.ToString(),
                       Gender.ToString(),
                       Age.ToString(),
                       CurrentHP.ToString(),
                       MaxHP.ToString(),
                       Exp.ToString(),
                       Armored.ToString()
                       ));

            ;
        }
Ejemplo n.º 4
0
 public Cleric(string name, int maxHealth, ETargetType targetType)
     : base(name, "Cleric", maxHealth, targetType)
 {
     Abilities[0] = new Regular(new Prayer());
     Abilities[1] = new Armored(new Shieldslam(), 3);
     Abilities[2] = new Regular(new Heal());
     Abilities[3] = new Evade(new Dodge(), 0.25f);
     Abilities[4] = new Armored(new Bare("Chest", "Bare Chest"), 3);
     Abilities[5] = new Vulnerable(new Bare("Back", "Your bare back"));
 }
Ejemplo n.º 5
0
 public Warrior(string name, int maxHealth, ETargetType targetType)
     : base(name, "Warrior", maxHealth, targetType)
 {
     Abilities[0] = new Regular(new Headbutt());
     Abilities[1] = new Armored(new Shieldslam(), 3);
     Abilities[2] = new Regular(new Slash());
     Abilities[3] = new Regular(new Kick());
     Abilities[4] = new Regular(new Tackle());
     Abilities[5] = new Vulnerable(new Bare("Back", "Your bare back"));
 }
Ejemplo n.º 6
0
    /*
     * Updates the counters for the effects currently on the player.
     * Called in Character.cs's NewEffect(), an override of a method in Unit.cs.
     */
    public void updateEffectTimers(Effect effect)
    {
        Debug.Log("Called updateEffectTimers. effect name is " + effect.effectName);
        switch (effect.effectName)
        {
        case "Empowered":
        {
            if (effect.isLongest)
            {
                longestEmp = (Empowered)effect;
            }
            Debug.Log("Setting longestEmp.");
            break;
        }

        case "Regeneration":
        {
            if (effect.isLongest)
            {
                longestReg = (Regeneration)effect;
            }
            Debug.Log("Setting longestReg.");
            break;
        }

        case "Degeneration":
        {
            if (effect.isLongest)
            {
                longestDegen = (Degeneration)effect;
            }
            Debug.Log("Setting longestDegen.");
            break;
        }

        case "Burning":
        {
            if (effect.isLongest)
            {
                longestBurn = (Burning)effect;
            }
            Debug.Log("Setting longestBurn.");
            break;
        }

        case "Armored":
        {
            if (effect.isLongest)
            {
                longestArmor = (Armored)effect;
            }
            Debug.Log("Setting longestArmor.");
            break;
        }

        case "Focused":
        {
            if (effect.isLongest)
            {
                longestFocus = (Focused)effect;
            }
            Debug.Log("Setting longestFocus.");
            break;
        }

        case "Hasted":
        {
            if (effect.isLongest)
            {
                longestHaste = (Hasted)effect;
            }
            Debug.Log("Setting longestHaste.");
            break;
        }

        case "Swiftness":
        {
            if (effect.isLongest)
            {
                longestSwift = (Swiftness)effect;
            }
            Debug.Log("Setting longestSwift.");
            break;
        }

        case "Crippled":
        {
            if (effect.isLongest)
            {
                longestCrip = (Crippled)effect;
            }
            Debug.Log("Setting longestCrip.");
            break;
        }

        default:
        {
            Debug.Log("Invalid effect.");
            break;
        }
        }
    }
 public HistoryMajor()
 {
     health       = 22; maxHP = 22; strength = 4; power = 0; charge = 0; defense = 0; guard = 0;
     baseAccuracy = 11; accuracy = 11; dexterity = 1; evasion = 0; type = "History Major"; passive = new Armored(this);
     quirk        = Quirk.GetQuirk(this); special = new Joust(); special2 = new Tactics();
     player       = false; champion = false; recruitable = true; CreateDrops(); attackEffect = "gain 1 guard";
 }
Ejemplo n.º 8
0
    /*
     * Spawns bullet, return:
     *   dealt damage if it was dealt immediately
     *   0 if nothing was hit
     *  -1 if damage is not set to immediate
     *  -2 in case of unexpected error
     */
    private int SpawnBullet(float angle, float dis)
    {
        int dmgValue;

        Transform bullet = (Transform)Instantiate(bulletTrialPrefab, firingPoint.position, Quaternion.Euler(0, 0, angle));

        Bullet bulletScript = bullet.GetComponent <Bullet>();

        if (BulletHitDetection == DetectionMode.ExplosionWithCollider)
        {
            // Shoot the bullet, collision detection and damage or other animations will be made by the bullet itself

            bulletScript.rangeSubtract = bulletRangeSubtract;
            bulletScript.SetRange(dis);
            bulletScript.toHit           = toHit;
            bulletScript.parent          = transform.parent.parent.parent;
            bulletScript.explosionDamage = explosionDamage;
            bulletScript.explosionRadius = explosionRadius;

            dmgValue = -1;
        }
        else
        {
            // Bullet will be only there as decoration

            Vector2 start = firingPoint.parent.parent.position;
            Vector2 end   = new Vector2(start.x - GetX(angle, dis), start.y + GetY(angle, dis));

            Ray2D        ray       = new Ray2D(start, end - start);
            RaycastHit2D hit       = Physics2D.Raycast(start, end - start, dis, toHit);
            Vector2      direction = ray.direction;
            direction.Normalize();

            bulletScript.rangeSubtract = bulletRangeSubtract;
            if (hit.distance == 0)
            {
                bulletScript.SetRange(dis);
            }
            else
            {
                bulletScript.SetRange(hit.distance);
            }

            // Collision

            Collider2D col = hit.collider;

            if (col != null && col.transform != transform.parent.parent.parent.transform && toHit == (toHit | (1 << col.gameObject.layer))) // Check for hit
            {
                if (col.gameObject.GetComponent <Entity>() != null)
                {
                    // Bullet has hit an friend / enemy

                    if (col.gameObject.GetComponent <Armored>() == null)
                    {
                        // Entity has no armor

                        // Calc damage
                        dmgValue = Mathf.RoundToInt(Random.Range(0.8f * damage, 1.2f * damage));

                        // Apply
                        col.gameObject.GetComponent <Entity>().damage(dmgValue);
                        return(dmgValue);
                    }
                    else
                    {
                        // Entity has armor

                        // Calculate which side of the BoxCollider2D was hit

                        Vector2 hitPoint = start + (ray.direction * hit.distance);

                        Vector2 colCenter = col.bounds.center; // It's not the same as Call Center

                        Vector2 difference = hitPoint - colCenter;

                        float   ang   = Vector2.Angle(difference, col.transform.up);
                        Vector3 cross = Vector3.Cross(difference, col.transform.up);

                        if (cross.z > 0)
                        {
                            ang = 360 - ang;
                        }

                        if (ang > 180)
                        {
                            ang -= 360;
                        }

                        ang *= -1;

                        Armored armor = col.gameObject.GetComponent <Armored>();

                        int side = -1; // 0: Front, 1: Right, 2: Back, 3: Left

                        float armorAmount;

                        if (ang >= armor.angleFront && ang < armor.angleRight)
                        {
                            // Front

                            side = 0;

                            armorAmount = armor.FrontArmorMultiplier;
                        }
                        else if (ang >= armor.angleRight && ang < armor.angleBack)
                        {
                            // Right

                            side = 1;

                            armorAmount = armor.SideArmorMultiplier;
                        }
                        else if (ang >= armor.angleBack || ang < armor.angleLeft)
                        {
                            // Back

                            side = 2;

                            armorAmount = armor.BackArmorMultiplier;
                        }
                        else
                        {
                            // Left

                            side = 3;

                            armorAmount = armor.SideArmorMultiplier;
                        }

                        // Calculate number of sparks

                        int sparkNumber = Mathf.Clamp(Mathf.RoundToInt(.5f * Mathf.Sqrt(armorAmount * damage * Random.Range(1, 3))), 0, 30);

                        // Calculate rotation

                        float rot = col.transform.rotation.eulerAngles.z - side * 90;

                        // Add spark particles

                        GameObject container      = GameObject.Find("effects") ?? new GameObject("effects");
                        Transform  particleParent = (Transform)Instantiate(armor.HitPrefab, hitPoint, Quaternion.Euler(0, 0, rot), container.transform);

                        // spawn delayed

                        ParticleSystem particles = particleParent.Find("Particle System").GetComponent <ParticleSystem>();
                        float          delay     = hit.distance / bullet.GetComponent <Bullet>().moveSpeed * 0.1f;

                        IEnumerator SpawnDelayed(float time)
                        {
                            yield return(new WaitForSeconds(time));

                            try
                            {
                                particles.Emit(sparkNumber);
                            }
                            catch (Exception e)
                            {}
                        }

                        StartCoroutine(SpawnDelayed(delay));

                        Destroy(particleParent.gameObject, delay + 2f);

                        // Calc damage
                        dmgValue = Mathf.RoundToInt(Random.Range(0.8f * damage, 1.2f * damage) / armorAmount);

                        // Apply
                        col.gameObject.GetComponent <Entity>().damage(dmgValue);
                    }
                }
                else
                {
                    dmgValue = -2;     // unexpected error
                }
            }
            else
            {
                // nothing was hit

                dmgValue = 0;
            }

            // Disable Bullet when hitted object is very close

            if (col != null && hit.distance < bullet.localScale.y)
            {
                bullet.GetComponent <SpriteRenderer>().sprite = invisibleSprite;
            }
        }

        // Spawn Muzzle Flash

        if (muzzleFlashPrefab != null)
        {
            Transform muzzleFlash = (Transform)Instantiate(muzzleFlashPrefab, firingPoint.position, firingPoint.rotation, firingPoint);

            float size = Random.Range(0.8f, 1.1f);

            Vector3 oldSize = muzzleFlash.localScale;
            muzzleFlash.localScale = new Vector3(oldSize.x * size, oldSize.y * size, 0);

            Destroy(muzzleFlash.gameObject, 0.02f * muzzleFlash.localScale.x);
        }

        return(dmgValue);
    }