示例#1
0
    public static Hitbox CreateHitbox(GameObject owner, Dictionary <string, string> dict)
    {
        GameObject hboxObj = GameObject.CreatePrimitive(PrimitiveType.Cube);

        hboxObj.name = "Hitbox";
        Hitbox hbox = hboxObj.AddComponent <Hitbox>();

        hbox.transform.SetParent(owner.transform);

        hbox.owner = owner.GetComponent <BattleObject>();

        Renderer rend = hbox.GetComponent <Renderer>();
        Material mat  = rend.material;

        mat.SetColor("_Color", new Color(1.0f, 0, 0, 0.5f));
        StandardShaderUtils.ChangeRenderMode(mat, StandardShaderUtils.BlendMode.Transparent);

        //Load all the hitbox info from the dict of values generated by the subaction
        hbox.LoadValuesFromDict(dict);
        hbox.SizeToOwner(owner.GetComponent <BattleObject>());
        //FIXME hitbox locks are odd. They're attached to actions for some reason?
        HitboxLock new_lock = new HitboxLock(hbox.lock_name);

        hbox.hitbox_lock = new_lock;

        return(hbox);
    }
    /////////////////////////////////////////////////////////////////////////////////////////
    //                              PRIVATE HELPER METHODS                                 //
    /////////////////////////////////////////////////////////////////////////////////////////

    private IEnumerator RemoveLock(HitboxLock hitbox_lock)
    {
        yield return(new WaitForSeconds(2));

        if (hitbox_locks.Contains(hitbox_lock)) //It can be unlocked later
        {
            hitbox_locks.Remove(hitbox_lock);
        }
    }
示例#3
0
 /// <summary>
 /// Creates or loads a HitboxLock, an object preventing multiple hitboxes from all affecting a target at once if they should be part of the same attack
 /// </summary>
 private static void LockHitbox(GameAction action, Hitbox hbox)
 {
     //Set up the hitbox lock, if applicable
     if (hbox.lock_name != "")                                //If it has a name, we need to check if it's got a lock already
     {
         if (action.hitbox_locks.ContainsKey(hbox.lock_name)) //If it's already there, just assign it to the hitbox
         {
             hbox.hitbox_lock = action.hitbox_locks[hbox.lock_name];
         }
         else //If it has a name, but isn't in the list, we need to add it
         {
             HitboxLock new_lock = new HitboxLock(hbox.lock_name);
             hbox.hitbox_lock = new_lock;
             action.hitbox_locks.Add(hbox.lock_name, new_lock);
         }
     }
     else //If it's unnamed, we just need to create a new lock for this hitbox
     {
         HitboxLock new_lock = new HitboxLock("GenericLockName" + action.hitbox_locks.Count.ToString());
         hbox.hitbox_lock = new_lock;
         action.hitbox_locks.Add(new_lock.name, new_lock);
     }
 }