Ejemplo n.º 1
0
 public bool OnDamage(int t, WarSceneController.Direction dir, bool isFire)
 {
     if (isFire)
     {
         SetOnFire();
     }
     return(OnDamage(t, dir));
 }
Ejemplo n.º 2
0
    public void SetRangedWeapon(WarSceneController.WhichSide s, WarSceneController.Direction d, int t, Vector3 pos)
    {
        int          idx = t - 3;
        GameObject   go  = (GameObject)Instantiate(rangedWeaponPrefab[idx]);
        RangedWeapon rw  = go.AddComponent <RangedWeapon>();

        rw.Init(s, d, t, pos, transform, warCtrl);
    }
Ejemplo n.º 3
0
    void OnFightingAct()
    {
        if (anim.IsPlaying())
        {
            if (anim.GetCurFrameIndex() == 2 && !hadCheckAttack)
            {
                hadCheckAttack = true;

                if (soliderType == 3 || soliderType == 4 || soliderType == 5)
                {
                    WarSceneController.Direction dir = WarSceneController.Direction.Left;
                    if (transform.localScale.x < 0)
                    {
                        dir = WarSceneController.Direction.Right;
                    }
                    rwCrt.SetRangedWeapon(side, dir, soliderType, transform.localPosition);
                }
                else
                {
                    if (transform.localScale.x < 0)
                    {
                        if (warCtrl.OnSoliderHitChecking(side, soliderType, WarSceneController.Direction.Right, hitDistance1, locationX, locationY))
                        {
                            targetEnemy = null;
                        }
                    }
                    else
                    {
                        if (warCtrl.OnSoliderHitChecking(side, soliderType, WarSceneController.Direction.Left, hitDistance1, locationX, locationY))
                        {
                            targetEnemy = null;
                        }
                    }
                }
            }
        }
        else
        {
            hadCheckAttack   = false;
            isFighting       = false;
            timeCoolDownTick = timeCoolDown;

            anim.Play("Idle");
        }
    }
Ejemplo n.º 4
0
    public void Init(WarSceneController.WhichSide s, WarSceneController.Direction d, int t, Vector3 pos, Transform parent, WarSceneController ws)
    {
        side    = s;
        dir     = d;
        type    = t;
        warCtrl = ws;

        transform.parent                    = parent;
        transform.localPosition             = pos;
        transform.GetChild(0).localPosition = offset;

        if (dir == WarSceneController.Direction.Left)
        {
            speed = -speed;
            transform.localScale = WarSceneController.manScaleRight;
        }
        else
        {
            transform.localScale = WarSceneController.manScaleLeft;
        }
        orgPosX = transform.localPosition.x;

        transform.localEulerAngles = WarSceneController.manEulerAngles;
    }
Ejemplo n.º 5
0
    // Update is called once per frame
    void Update()
    {
        if (WarSceneController.isGamePause)
        {
            return;
        }

        if (WarSceneController.state == WarSceneController.State.Beginning ||
            WarSceneController.state == WarSceneController.State.Menu ||
            WarSceneController.state == WarSceneController.State.End ||
            WarSceneController.state == WarSceneController.State.Assault)
        {
            return;
        }

        if (state == 0)
        {
            Vector3 pos = transform.localPosition;

            pos.x += speed * Time.deltaTime;
            if (pos.x >= WarSceneController.manPosMaxX - 100 || pos.x <= -WarSceneController.manPosMaxX + 100 ||
                Mathf.Abs(pos.x - orgPosX) > 1000)
            {
                Destroy(gameObject);
                return;
            }
            transform.localPosition = pos;

            int locationX = warCtrl.GetLocationPositionX(transform.localPosition.x);
            int locationY = warCtrl.GetLocationPositionY(transform.localPosition.y);
//			int locationX = (int)((pos.x + WarSceneController.manPosMaxX) / WarSceneController.locationStepX);
//			int locationY = (int)((pos.y + WarSceneController.manPosMaxY) / WarSceneController.locationStepY);

            if (warCtrl.GetLocationIsEnemy(side, locationX, locationY))
            {
                WarSceneController.Direction dir = WarSceneController.Direction.Left;
                if (speed > 0)
                {
                    dir = WarSceneController.Direction.Right;
                }
                if (warCtrl.OnSoliderHitChecking(side, type, dir, 1, locationX, locationY))
                {
                    Destroy(gameObject);
                }
                else
                {
                    state = 1;
                    anim.PlayDefault();
                }
            }
        }
        else
        {
            timeTick += Time.deltaTime;
            transform.localPosition = new Vector3(transform.localPosition.x - speed / 5 * Time.deltaTime,
                                                  transform.localPosition.y + upspeed * Time.deltaTime, transform.localPosition.z);
            if (timeTick < 0.5f)
            {
                sprite.color = new Color(1, 1, 1, 1 - 2 * timeTick);
            }
            else
            {
                Destroy(gameObject);
            }
        }
    }
Ejemplo n.º 6
0
    public bool OnDamage(int t, WarSceneController.Direction dir)
    {
        if (state == State.Dead)
        {
            return(false);
        }

        bool flag  = true;
        int  block = 50;

        switch (t)
        {
        case -1:
            block = 0;
            break;

        case 1000:
            block = 50;
            break;

        case 0:
            if (soliderType == 3 || soliderType == 4 || soliderType == 5)
            {
                block = 20;
            }
            else if (soliderType == 1 || soliderType == 2 || soliderType == 8)
            {
                block = 70;
            }
            break;

        case 1:
            if (soliderType == 0 || soliderType == 6 || soliderType == 10)
            {
                block = 30;
            }
            else if (soliderType == 3 || soliderType == 4 || soliderType == 5)
            {
                block = 70;
            }
            break;

        case 2:
            if (soliderType == 0 || soliderType == 7 || soliderType == 10)
            {
                block = 30;
            }
            else if (soliderType == 3 || soliderType == 4 || soliderType == 5)
            {
                block = 70;
            }
            break;

        case 3:
        case 4:
        case 5:
            if (soliderType == 1 || soliderType == 2 || soliderType == 6 || soliderType == 8 || soliderType == 10)
            {
                block = 30;
            }
            else if (soliderType == 0 || soliderType == 7 || soliderType == 9)
            {
                block = 80;
            }
            break;

        case 6:
            if (soliderType == 2 || soliderType == 8 || soliderType == 10)
            {
                block = 30;
            }
            else if (soliderType == 1 || soliderType == 3 || soliderType == 9)
            {
                block = 70;
            }
            break;

        case 7:
            if (soliderType == 3 || soliderType == 4 || soliderType == 5)
            {
                block = 25;
            }
            else if (soliderType == 1 || soliderType == 2 || soliderType == 8)
            {
                block = 65;
            }
            break;

        case 8:
            if (soliderType == 0 || soliderType == 7 || soliderType == 10)
            {
                block = 25;
            }
            else if (soliderType == 3 || soliderType == 4 || soliderType == 5)
            {
                block = 65;
            }
            break;

        case 9:
            if (soliderType == 3 || soliderType == 4 || soliderType == 5)
            {
                block = 25;
            }
            else if (soliderType == 1 || soliderType == 2 || soliderType == 8)
            {
                block = 65;
            }
            break;

        case 10:
            block = 60;
            break;
        }

        int rand = Random.Range(0, 100);

        if (block > rand)
        {
            flag = false;
        }

        if (!flag)
        {
            if (!isFighting)
            {
                isParrying = true;
                timeTick   = 0;

                anim.Stop();
                anim.SetFrame("Parry", 0);
            }
            return(false);
        }

        if (isKnight)
        {
            if (t != -1 && life > 1)
            {
                life--;
                return(false);
            }
        }

        SoundController.Instance.PlaySound3D("00036", transform.position);

        state    = State.Dead;
        timeTick = 0;
        anim.Stop();
        anim.SetFrame("Dead", 0);

        if ((dir == WarSceneController.Direction.Left && transform.localScale.x > 0) ||
            (dir == WarSceneController.Direction.Right && transform.localScale.x < 0))
        {
            transform.localScale = new Vector3(-transform.localScale.x, transform.localScale.y, transform.localScale.z);
        }

        if (isKnight && soliderType != 6)
        {
            Transform horse = transform.GetChild(0);
            horse.gameObject.SetActive(true);
            horse.parent = transform.parent;
            horse.GetComponent <SolidersHorse>().SetHorseRun();

            warCtrl.AddSoliderHorse(horse.GetComponent <SolidersHorse>());
        }

        Vector3 pos = transform.localPosition;

        pos += deadBodyOffset;
        transform.localPosition = pos;

        warCtrl.RemoveSolider(index);
        Destroy(mapPoint.gameObject);

        return(true);
    }