public void Awake()
 {
     rigid = gameObject.GetComponent<Rigidbody2D>();
     sp = GameObject.FindGameObjectWithTag (Tags.gameController).GetComponent<SpFunctions> ();
     col=GetComponentInChildren<CollisionRegulation>();
     hitControl = GetComponentInChildren<HitController> ();
 }
Example #2
0
	protected override void OnHitKnockBack(HitController target) {
		base.OnHitKnockBack (target);
		if (player.facingRight ()) {
			target.Launch (new Vector2 (3, 2), baseKnockback + knockbackGrowth * targetPercentage);
		} else {
			target.Launch (new Vector2 (-3, 2), baseKnockback + knockbackGrowth * targetPercentage);
		}
	}
Example #3
0
	protected override void OnHitKnockBack(HitController target) {
		base.OnHitKnockBack (target);
		Vector2 launchDirection = target.transform.position - player.getTransform ().position;
		if (launchDirection.x >= 0) {
			target.Launch (new Vector2 (1, 3), baseKnockback + knockbackGrowth * targetPercentage);
		} else {
			target.Launch (new Vector2 (-1, 3), baseKnockback + knockbackGrowth * targetPercentage);
		}
	}
Example #4
0
	protected override void OnHitKnockBack(HitController target) {
		base.OnHitKnockBack (target);
		Vector2 launchDirection = target.transform.position - player.getTransform ().position;
		if (Vector2.Angle(Vector2.up, launchDirection) >= 45) {
			if (launchDirection.x >= 0)
				launchDirection = new Vector2 (1, 1);
			else
				launchDirection = new Vector2 (-1, 1);
		}
		target.Launch (launchDirection, baseKnockback + knockbackGrowth * targetPercentage);
	}
    public void SetValues(RootCharacterController c,
	                      WeaponClass w,
	                      int n, int b, int e,
	                      SpFunctions s,
	                      HitController h)
    {
        bTime = b; eTime = e; controller = c; weapon = w; numb = n;
        activity = weapon.moveset [numb];
        stats = controller.gameObject.GetComponent<Stats> ();
        sp = s;
        hitBox = h;
    }
Example #6
0
 protected override void OnHitKnockBack(HitController target)
 {
     base.OnHitKnockBack(target);
     if (player.facingRight())
     {
         target.Launch(new Vector2(-2, 1), baseKnockback + knockbackGrowth * targetPercentage);
     }
     else
     {
         target.Launch(new Vector2(2, 1), baseKnockback + knockbackGrowth * targetPercentage);
     }
 }
	// Use this for initialization
	void Start () {
		fighter = GetComponent<Fighter> ();
		player = fighter.getPlayer ();
		UIPercentage[] UIs = FindObjectsOfType<UIPercentage> ();
		Debug.Log (player.ToString());
		for (int i = 0; i < UIs.Length; i++) {
			if (UIs [i].player == player) {
				UI = UIs [i];
				break;
			}
		}
		hit = GetComponentInChildren<HitController> ();
	}
Example #8
0
    protected override void OnHitKnockBack(HitController target)
    {
        base.OnHitKnockBack(target);
        Vector2 launchDirection = target.transform.position - player.getTransform().position;

        if (launchDirection.x >= 0)
        {
            target.Launch(new Vector2(1, 3), baseKnockback + knockbackGrowth * targetPercentage);
        }
        else
        {
            target.Launch(new Vector2(-1, 3), baseKnockback + knockbackGrowth * targetPercentage);
        }
    }
 // Use this for initialization
 void Start()
 {
     fighter = GetComponent <Fighter> ();
     player  = fighter.getPlayer();
     UIPercentage[] UIs = FindObjectsOfType <UIPercentage> ();
     Debug.Log(player.ToString());
     for (int i = 0; i < UIs.Length; i++)
     {
         if (UIs [i].player == player)
         {
             UI = UIs [i];
             break;
         }
     }
     hit = GetComponentInChildren <HitController> ();
 }
Example #10
0
    /*
     * void FixedUpdate() {
     *      frameLeft--;
     *      if (frameLeft <= 0) {
     *              //Destroy (this.gameObject);
     *              this.gameObject.SetActive(false);
     *      }
     * }
     */


    void OnTriggerEnter2D(Collider2D col)
    {
        //if (!isServer)
        //return;
        if (Owner != null)
        {
            if (ReferenceEquals(col.gameObject.GetComponentInParent <Fighter>(), Owner))
            {
                return;
            }
        }
        if (TargetsHit.Contains(col.gameObject.GetComponentInParent <Fighter> ()))
        {
            return;
        }
        TargetsHit.Add(col.gameObject.GetComponentInParent <Fighter> ());

        if (col.gameObject.tag == "Shield")
        {
            ShieldController target = col.gameObject.GetComponentInParent <ShieldController> ();
            Debug.Log("Hit " + col.gameObject.GetComponentInParent <Fighter> ().getName() + "'s shield!");
            target.TakeDamage(shieldDamage);
            target.HitStun(shieldHitStunDuration);
            OnShieldKnockBack(target);
            return;
        }
        if (col.gameObject.tag == "HurtBox")
        {
            HitController target = col.gameObject.GetComponent <HitController> ();
            Debug.Log("Hit " + col.gameObject.GetComponentInParent <Fighter> ().getName() + "!");
            if (HitEffect != null)
            {
                GameObject hit = (GameObject)Instantiate(HitEffect, transform.position, Quaternion.identity);
                Destroy(hit, 1f);
            }

            target.TakeDamage(damage);
            target.HitStun(hitStunDuration);
            OnHitKnockBack(target);
        }
    }
Example #11
0
    private float m_StartTime = 0;      //start time

    //create
    public static HitController Create(GfxObject gfx, ActionObject.Hit hit, HitData hitdata, EffectController effectController, GfxObject target)
    {
        GameObject    obj           = new GameObject("HitController");
        HitController hitController = obj.AddComponent <HitController>();
        BoxCollider   col           = obj.AddComponent <BoxCollider>();

        hitController.m_Owner  = gfx;
        hitController.m_Target = target;

        Transform trans = null;

        if (hit.bindEffect)
        {
            trans = effectController.gameObject.transform.Find(hit.parent);
        }
        else
        {
            trans = gfx.gameObject.transform.Find(hit.parent);
        }

        if (trans != null)
        {
            obj.transform.parent = trans;
        }

        obj.transform.localScale = hit.size;
        col.size      = Vector3.one;
        col.center    = Vector3.zero;
        col.isTrigger = true;

        obj.transform.localPosition = hit.offset;
        hitController.m_Time        = hit.time;
        hitController.m_HitData     = hitdata;

        obj.transform.localRotation = Quaternion.Euler(hit.rotate);

        hitController.m_StartTime = Time.time;

        return(hitController);
    }
Example #12
0
    private void Start()
    {
        hitController = GameObject.FindGameObjectWithTag("PlayerController")
                        .GetComponent <HitController>();

        Cursor.lockState = CursorLockMode.Locked;

        Turn   = 1;
        bodies = FindObjectsOfType <CelestialBody>();

        objectives = FindObjectsOfType <ObjectiveDefinition>();
        foreach (ObjectiveDefinition objective in objectives)
        {
            objective.completed.AddListener(UpdateObjectives);
        }
        UpdateObjectives();

        completionText.gameObject.SetActive(false);
        nextLevelButton.gameObject.SetActive(false);

        cam     = Camera.main;
        cueBall = GameObject.FindGameObjectWithTag("CueBall");
    }
    //beginTime должен быть больше endTime
    //тип 2 номер 3
    public void WeaponPush(HitController hitControl, Rigidbody2D rigid, 
	                      float pDamage,float fDamage,float dDamage,float aDamage,
	                      int attack,
	                      bool backStab,
	                      float backStabKoof, int time, int beginTime, int endTime, int timeToPush,
	                      Vector2 fVect)
    {
        int i;
        bool b=false;
        hitControl.pDamage = pDamage;
        hitControl.fDamage = fDamage;
        hitControl.dDamage = dDamage;
        hitControl.aDamage = aDamage;
        hitControl.attack = attack;
        hitControl.backStab = backStab;
        hitControl.backStabKoof = backStabKoof;
        if (hitControl.actTime==0)
            hitControl.actTime= time;
        if ((hitControl.actTime > endTime)&&(hitControl.actTime<=beginTime))
            hitControl.GetComponent<BoxCollider2D> ().enabled = true;
        else if (hitControl.actTime >beginTime)
            hitControl.GetComponent<BoxCollider2D> ().enabled = false;
        for (i=0; i<hitControl.list.Count; i++)
            if (hitControl.list [i] != rigid.gameObject)
                b = true;
        if ((b)&&(hitControl.actTime==timeToPush))
        {
            if (rigid.gameObject.GetComponent<Stats>()!=null)
            {
                if (rigid.gameObject.GetComponent<Stats>().stats.groundness==4)
                    rigid.AddForce(fVect);
            }
            else
                rigid.AddForce(fVect);
        }
    }
    //beginTime должен быть больше endTime
    /*//тип 2 номер 1
    public void WeaponMove(Equipment equip, RootCharacterController control, Stats stats, SpFunctions Sp, bool isItRight)
    {
        WeaponClass weapon;
        if (isItRight)
            weapon = equip.rightWeapon;
        else
            weapon = equip.leftWeapon;
        int i;
        int j=-1;
        Rigidbody2D rigid = control.gameObject.rigidbody2D;
        clavisher clav = Sp.gameObject.GetComponent<clavisher> ();
        for (i=weapon.moveset.Length-1; i>=0; i--)
        {
            if (Sp.ClaveComparation(weapon.moveset[i].why.claves,clav))
                if (Sp.FComparation(Mathf.Abs(rigid.velocity.x),weapon.moveset[i].why.speedX*1f)&&
                    Sp.FComparation(Mathf.Abs(rigid.velocity.y),weapon.moveset[i].why.speedY*1f)&&
                    (weapon.moveset[i].why.employment<=stats.stats.employment)&&
                    Sp.IntComparation(stats.stats.direction+2, weapon.moveset[i].why.direction)&&
                    Sp.IntComparation(stats.stats.groundness,weapon.moveset[i].why.groundness)&&
                    Sp.IntComparation(stats.stats.obstacleness,weapon.moveset[i].why.obstacleness)&&
                    Sp.IntComparation(stats.stats.groundness,weapon.moveset[i].why.groundness)&&
                    Sp.ComprFunctionality(stats.stats.maxInteraction,weapon.moveset[i].why.maxinteraction)&&
                    Sp.ComprFunctionality(stats.stats.interaction,weapon.moveset[i].why.interaction)&&
                    Sp.IntComparation(stats.stats.upness,weapon.moveset[i].why.upness)&&
                    Sp.IntComparation(stats.stats.specialness,weapon.moveset[i].why.specialness)&&
                    (!weapon.moveset[i].chosen))
                {
                    j=i;
                    break;
                }
        }
        if (j>=0)
        {
            control.activityNumb=Sp.AddActivity(control.whatToEmploy,weapon.moveset[j],control.activityNumb);
            stats.stats.employment-=weapon.moveset[j].employ;
            if (weapon.moveset[j].soWhat.groundness>=0) stats.stats.groundness=weapon.moveset[j].soWhat.groundness;
            if (weapon.moveset[j].soWhat.obstacleness>=0) stats.stats.obstacleness=weapon.moveset[j].soWhat.obstacleness;
            if (weapon.moveset[j].soWhat.interaction>=0)stats.stats.interaction=weapon.moveset[j].soWhat.interaction;
            if (weapon.moveset[j].soWhat.specialness>=0)stats.stats.specialness=weapon.moveset[j].soWhat.specialness;
            weapon.moveset[i].chosen=true;
        }
    }*/
    //тип 2 номер 2
    public void WeaponHit(HitController hitControl, 
	                      float pDamage,float fDamage,float dDamage,float aDamage,
	                      int attack,
	                      bool backStab,
	                      float backStabKoof, int time, int beginTime, int endTime, int direction)
    {
        hitControl.pDamage = pDamage;
        hitControl.fDamage = fDamage;
        hitControl.dDamage = dDamage;
        hitControl.aDamage = aDamage;
        hitControl.attack = attack;
        hitControl.backStab = backStab;
        hitControl.backStabKoof = backStabKoof;
        if (hitControl.actTime==0)
            hitControl.actTime= time;
        if ((hitControl.actTime > endTime)&&(hitControl.actTime<=beginTime))
            hitControl.GetComponent<BoxCollider2D> ().enabled = true;
        else if (hitControl.actTime >beginTime)
            hitControl.GetComponent<BoxCollider2D> ().enabled = false;
        hitControl.direction = direction;
    }
    //тип 6 номер 5
    public void Punchuntiltarget(PunchUntilTarget p, 
	                             RootCharacterController c,
	                             WeaponClass w,
	                             int n, int b, int e,
	                             SpFunctions s,
	                             HitController h)
    {
        if (p.stage == 0)
            p.SetValues (c, w, n, b, e, s, h);
        p.Work ();
    }
    //тип 6 номер 3
    public void Holdandunleash(HoldAndUnleash hld, 
	                             RootCharacterController c,
	                             WeaponClass w,
	                             int n, int b, int e, int cN,
	                             SpFunctions s,
	                             HitController h,
	                           clavisher cl)
    {
        if (hld.stage == 0)
            hld.SetValues (c, w, n, b, e,cN, s, h, cl);
        hld.Work ();
    }
Example #17
0
	protected virtual void OnHitKnockBack(HitController target) {
		targetPercentage = target.GetPercentage ();
	}
    //update
    void Update()
    {
        if (null == owner)
        {
            return;
        }
        if (m_Table == null)
        {
            GameObject.Destroy(this.gameObject);
            return;
        }

        float time = Time.time - this.m_StartTime;

        ActionObject actionOld = currentAction;
        ActionObject ac        = null;

        time          = GetCurrentAction(time, out ac);
        currentAction = ac;

        List <ActionObject.Event> events = new List <ActionObject.Event>();

        if (ac == null)
        {
            //over
            GameObject.Destroy(this.gameObject);
            return;
        }

        if (ac != actionOld)            //add old unexcute event
        {
            if (actionOld != null)
            {
                events.AddRange(GetEvents(actionOld, cur_old_time, cur_now_time));
            }
        }

        UpdateTime(time);                                           //update time
        UpdateAnime(ac);                                            //update animation
        events.AddRange(GetEvents(ac, cur_old_time, cur_now_time)); //add current event
        if (events.Count > 0)
        {
            foreach (ActionObject.Event ev in events)
            {
                if (ev.messages.Count > 0)
                {
                    for (int i = 0; i < ev.messages.Count; i++)
                    {
                        owner.SendMessage("SkillMessage", ev.messages[i].m_Function + ";" + ev.messages[i].m_Args);
                    }
                }
                EffectController effectController = null;
                if (ev.effect.id != string.Empty)
                {
                    if (ev.effect.onoff)
                    {
                        //create effect
                        effectController = EffectManager.I.Create(owner, ev.effect, this.m_HitData, target);
                        if (effectController != null)
                        {
                            //todo
                        }
                    }
                }
                if (ev.hit.onoff)
                {
                    GfxObject tmpTarget = null;
                    if (ev.hit.isTarget)
                    {
                        tmpTarget = target;
                    }
                    HitController hitController = HitController.Create(owner, ev.hit, this.m_HitData, effectController, tmpTarget);
                    if (hitController != null)
                    {
                        //todo
#if UNITY_EDITOR
                        //action editor
                        if (EditorSceneManager.GetActiveScene().name == "Assets/Scripts/Editor/CharacterEffectEditor.unity")
                        {
                            int damage_num = (int)(UnityEngine.Random.value * 1000f);
                            // HitNumber.SetData(hitController.transform.position, damage_num, HitNumberType.HpDown);
                        }
#endif
                    }
                }
                if (!string.IsNullOrEmpty(ev.sound))
                {
                    //play sound
                }
            }
        }

        return;
    }
Example #19
0
    // Start is called before the first frame update
    void Start()
    {
        GameObject objColliderTriggerParent = gameObject.transform.root.gameObject;

        colliderTriggerParent = objColliderTriggerParent.GetComponent <HitController>();
    }
Example #20
0
    // Update is called once per frame
    void Update()
    {
        if (shotEffects)                                                                                                //turn off shot effects if they were turned on
        {
            accTime2 -= Time.deltaTime;

            if (accTime2 <= 0)
            {
                shotLight.enabled     = false;
                shotParticles.enabled = false;
                shotEffects           = false;
                accTime2 = effectDuration;
            }
        }
        if (shooting)
        {
            accTime -= Time.deltaTime;

            if (accTime <= 0)                                                                                           //time to shoot a "bullet"
            {
                shotEffects       = true;
                shotLight.enabled = true;
                MakeSounds();                                       //TRIGGER GUNSHOT SOUND FROM HERE
                shotParticles.enabled = false;
                shotParticles.enabled = true;

                shootRay.origin    = transform.position;
                shootRay.direction = transform.forward;

                RaycastHit[] hits;
                hits = Physics.RaycastAll(shootRay, range, playerMask);
                for (int i = 0; i < hits.Length; i++)
                {
                    HitController playerHit = hits[i].collider.GetComponent <HitController>();
                    if (gunType == 0)
                    {
                        System.Random random = new System.Random();
                        int           num    = random.Next(0, 5);
                        if (num == 0)
                        {
                            playerHit.getHit(hits [i].point, true);
                        }
                        else
                        {
                            playerHit.getHit(hits [i].point, false);
                        }
                    }
                    else
                    {
                        playerHit.getHit(hits [i].point, true);
                    }
                }
                if (gunType == 0)
                {
                    accTime = timeBShots;
                }
                else
                {
                    System.Random random = new System.Random();
                    int           min    = (int)(timeBShots * 100 * 0.75);
                    int           max    = (int)(timeBShots * 100 * 1.25);
                    accTime = random.Next(min, max) / 100.0;
                    print("\nWait Time: " + accTime);
                }
            }
        }
    }
Example #21
0
 public HitControllerTest()
 {
     controller = new HitController();
 }
Example #22
0
 protected virtual void OnHitKnockBack(HitController target)
 {
     targetPercentage = target.GetPercentage();
 }
Example #23
0
 private void Awake()
 {
     _rigid = this.GetComponentInChildren <Rigidbody2D>();
     _anim  = this.GetComponent <Animator>();
     _hit   = this.GetComponent <HitController>();
 }