Exemple #1
0
    // Use this for initialization
    void Start()
    {
        //Because applySllow can happen before start, have initialTimeFactor variable (MUST BE A BETTER SOLUTION)
        if (initTimeFactor == 0)
        {
            initTimeFactor = 1;
        }

        curSpeed = SET_SPEED * initTimeFactor;

        if (GetComponentInParent <JumpArcherBehavior>().getTarget() == null)
        {
            throw new System.Exception("Error: Nothing to aim");
        }

        //Create direction
        Vector3 startingPos = GetComponentInParent <Transform>().position;
        Vector3 terminalPos = GetComponentInParent <JumpArcherBehavior>().getTarget().position;

        direction = SystemCalc.findDirection(startingPos, terminalPos);

        //Create Damage Package
        float damage = GetComponent <ProjectileStatus>().damage;

        dmgPackage = new DamagePackage(damage, direction * KNOCKBACK_VAL);

        //Time out variables
        curDistance = 0;

        //detach from parent while maintaining reference to source
        GetComponent <ProjectileStatus>().source = transform.root;
        transform.parent = null;
    }
Exemple #2
0
    // Use this for initialization
    void Start()
    {
        if (GetComponentInParent <FlyShooterBehav>().getTarget() == null)
        {
            throw new System.Exception("Error: Nothing to aim");
        }

        //Create direction
        Vector3 startingPos = GetComponentInParent <Transform>().position;
        Vector3 terminalPos = GetComponentInParent <FlyShooterBehav>().getTarget().position;

        direction = SystemCalc.findDirection(startingPos, terminalPos);
        curSpeed  = SET_SPEED;

        //Create Damage Package
        float damage = GetComponent <ProjectileStatus>().damage;

        dmgPackage = new DamagePackage(damage, direction * KNOCKBACK_VAL);

        //Time out variables
        curDistance = 0;

        //detach from parent while maintaining reference to source
        GetComponent <ProjectileStatus>().source = transform.root;
        transform.parent = null;
    }
    //Have player recoil when initiated
    IEnumerator recoil(Collider initiator)
    {
        //Create knockback
        Vector3 knockback = SystemCalc.findDirection(initiator.bounds.center, GetComponent <Transform>().position);

        knockback *= TAIL_KNOCKBACK;

        //Apply knockback
        Rigidbody parentRB = transform.parent.GetComponent <Rigidbody>();

        parentRB.velocity = Vector3.zero;
        parentRB.AddForce(knockback);

        yield return(new WaitForSeconds(RECOIL_DURATION));

        //Cancel knockback and destroy gameObject
        if (parentRB.velocity.y >= 0)
        {
            parentRB.velocity = Vector3.zero;
        }
        else
        {
            parentRB.velocity = new Vector3(0, parentRB.velocity.y, 0);
        }

        Object.Destroy(gameObject);
    }
Exemple #4
0
        public void Calc74in10to16systemIs4A()
        {
            var calc   = new SystemCalc(10.ToString(), 16, 74.ToString());
            var result = calc.Calculate();

            Assert.AreEqual("4A", result);
        }
Exemple #5
0
        public void Calc74in10to7systemIs134()
        {
            var calc   = new SystemCalc(10.ToString(), 7, 74.ToString());
            var result = calc.Calculate();

            Assert.AreEqual("134", result);
        }
Exemple #6
0
        public void Calc74in10to2system1001010()
        {
            var calc   = new SystemCalc(10.ToString(), 2, 74.ToString());
            var result = calc.Calculate();

            Assert.AreEqual("1001010", result);
        }
 // Update is called once per frame
 void FixedUpdate()
 {
     //Checks if target is found, move player
     if (target != null)
     {
         direction       = SystemCalc.findDirection(enemy.position, target.position);
         enemy.position += direction * curSpeed;
     }
 }
    // Update is called once per frame
    void FixedUpdate()
    {
        //Activates enemy once
        if (target != null)
        {
            //Projectile Timer
            if (attackInterval.getTime() == 0)  //If attack interval == 0, reset.
            {
                attackInterval.start();
            }

            if (attackInterval.getTime() >= curMaxInterval && !shooting) //If attack interval > set interval, spawn projectile
            {
                StartCoroutine(shootProjectile());
            }

            //Movement
            float   distance = SystemCalc.findDistance(target.position, enemy.position);
            Vector3 direction;

            //Decide whether to go towards player or away from player depending on distance
            if (distance > MAX_DISTANCE)
            {
                direction = SystemCalc.findDirection(enemy.position, target.position);
            }
            else if (distance < MIN_DISTANCE)
            {
                direction = SystemCalc.findDirection(target.position, enemy.position);
            }
            else
            {
                direction = Vector3.zero;
            }

            enemy.position += direction * curSpeed;
        }
    }
Exemple #9
0
    void CheckTouch()
    {
        if (SceneMain.Instance.isFixedSlime)
        {
            return;
        }

        var pos         = SceneMain.Instance.mainCamera.pixelCamera.ScreenToWorldPosition(Input.mousePosition);
        var nowTouchPos = new Vector2(pos.x, pos.y);

        if (!m_isTouch && Input.GetMouseButtonDown(0))
        {
            if ((Time.time - m_lastVelocityTime) < 0.5f)
            {
                return;
            }

            //タッチ開始
            m_isTouch       = true;
            m_beginTouchPos = nowTouchPos;
        }
        else if (m_isTouch && Input.GetMouseButton(0))
        {
            //タッチ中
            var vec      = nowTouchPos - m_beginTouchPos;
            var dis      = vec.magnitude;
            var isActive = (dis >= m_rangeDistance.MinValue);

            //設定によって変更
            switch (SaveManager.Instance.saveData.settingData.settingVelocityGuide)
            {
            case SettingVelocityGuide.None:
                break;

            case SettingVelocityGuide.Parabola:

                //放物線の座標を取得
                var positions = SystemCalc.GetBallisticpredictionPoint(
                    CalcVelocity(-vec.normalized),
                    transform.position,
                    m_parabolaDots.Length,
                    0.1f,
                    Physics2D.gravity.y * m_jellySprite.m_GravityScale);

                for (int i = 0; i < m_parabolaDots.Length; i++)
                {
                    if (!m_parabolaDots[i].activeSelf)
                    {
                        m_parabolaDots[i].SetActive(true);
                    }
                    m_parabolaDots[i].transform.position = positions[i];
                }

                break;

            case SettingVelocityGuide.Arrow:

                if (isActive)
                {
                    dis = Mathf.Clamp(dis, m_rangeDistance.MinValue, m_rangeDistance.MaxValue);
                    var disLerp = (dis - m_rangeDistance.MinValue) / m_rangeDistance.MinValue;
                    m_mainArrow.ChangeArrowLengh(disLerp, vec.normalized);
                }

                //表示の変更
                if (m_mainArrow.isActive != isActive)
                {
                    m_mainArrow.SetActive(isActive);
                }
                break;
            }
        }
        else if (m_isTouch && Input.GetMouseButtonUp(0))
        {
            //タッチ終了
            m_isTouch = false;

            //設定によって変更
            switch (SaveManager.Instance.saveData.settingData.settingVelocityGuide)
            {
            case SettingVelocityGuide.Arrow:
                //矢印が表示されているか
                if (m_mainArrow.isActive)
                {
                    var vec = (m_beginTouchPos - nowTouchPos).normalized;
                    AddForce(CalcVelocity(vec));
                    m_lastVelocityTime = Time.time;
                    m_mainArrow.SetActive(false);
                }
                break;

            case SettingVelocityGuide.Parabola:
                //放物線を非表示にする
                for (int i = 0; i < m_parabolaDots.Length; i++)
                {
                    m_parabolaDots[i].SetActive(false);
                }
                break;
            }
        }
    }
Exemple #10
0
    //Sets centralized knockback based on central position of attacker / projectile and central position of player
    //  Post: Sets knockback to a Vector3 that represents the direction from attacker to victim
    public void setCentralizedKnockback(Vector3 attackerPos, Vector3 victimPos, float knockbackValue)
    {
        Vector3 setKnockback = SystemCalc.findDirection(attackerPos, victimPos);

        knockback = setKnockback * knockbackValue;
    }