当前位置: 首页>>代码示例>>C++>>正文


C++ UnitObj类代码示例

本文整理汇总了C++中UnitObj的典型用法代码示例。如果您正苦于以下问题:C++ UnitObj类的具体用法?C++ UnitObj怎么用?C++ UnitObj使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了UnitObj类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Execute

    //
    // Execute
    //
    U32 Turn::Execute(const U8 *data, Player &player)
    {
      const Data *d = (Data *) data;

      // Send the move order to all of the selected objects
      for (UnitObjList::Iterator i(&player.GetSelectedList()); *i; i++)
      {
        UnitObj *unit = **i;

        // Calculate desired front vector
        Vector v(d->x - unit->Position().x, 0, d->z - unit->Position().z);
        v.Normalize();

        // Can the unit move
        if (unit->CanEverMove())
        {
          if (!unit->GetDriver()->IsBoarded())
          {
            // Convert the given task Id into a move type
            Tasks::UnitMove *task = new Tasks::UnitMove(unit);
            task->SetDir(v);
            IssueTask(d->mod, unit, task, player);
          }
        }
      }

      return (sizeof (Data));
    }
开发者ID:grasmanek94,项目名称:darkreign2,代码行数:31,代码来源:orders_game_turn.cpp

示例2: ASSERT

  //
  // TagCondition::TagTest
  //
  Bool TagCondition::TagTest(Team *team)
  {
    ASSERT(tag)
    U32 count = 0;

    // Test the Objects in Tag to see if there is enough of them on this team
    if (tag->tag.Alive())
    {
      // Purge dead objects out of the list
      tag->tag->list.PurgeDead();

      for (MapObjList::Iterator o(&tag->tag->list); *o; o++)
      {
        MapObj *obj = **o;
        UnitObj *unitObj = Promote::Object<UnitObjType, UnitObj>(obj);
        UnitObj *parentObj = obj->GetParent() ? Promote::Object<UnitObjType, UnitObj>(obj->GetParent()) : NULL;

        if (
          unitObj && (unitObj->GetActiveTeam() == team) || 
          parentObj && (parentObj->GetActiveTeam() == team))
        {
          count++;
        }
      }
    }

    return (tag->oper(count, tag->GetAmount()));
  }
开发者ID:ZhouWeikuan,项目名称:darkreign2,代码行数:31,代码来源:condition_game.cpp

示例3: Test

  //
  // TagInTransport::Test
  //
  Bool TagInTransport::Test(class Team *)
  {
    // Check to see if all of the tag members are inside transports
    if (tag->tag.Alive())
    {
      // Purge dead objects out of the list
      tag->tag->list.PurgeDead();

      // Count the number of tag members who are in transports
      U32 count = 0;

      if (tag->tag->list.GetCount())
      {
        for (MapObjList::Iterator o(&tag->tag->list); *o; o++)
        {
          MapObj *obj = **o;
          UnitObj *unitObj = Promote::Object<UnitObjType, UnitObj>(obj);

          if (unitObj && unitObj->GetFlag(UnitObj::FLAG_CARGO))
          {
            count++;
          }
        }
      }
      return (tag->oper(count, tag->GetAmount()));
    }
    return (FALSE);
  }
开发者ID:ZhouWeikuan,项目名称:darkreign2,代码行数:31,代码来源:condition_game.cpp

示例4: i

//
// Apply
//
void ExplosionObjType::Apply(const Vector &location, UnitObj *unit, Team *team)
{
  MapObjIter::All i(NULL, MapObjIter::FilterData(location, areaOuter));
  MapObj *obj;

  while ((obj = i.Next()) != NULL)
  {
    // Is the object within the full damage area
    F32 dist2 = i.GetProximity2() - areaInner2;
    S32 deltaHp;

    //Vector dir = obj->WorldMatrix().posit - location;
    //dir.Normalize();

    if (dist2 <= 0.0f)
    {
      // Apply the full damage to this object
      deltaHp = -damage.GetAmount(obj->MapType()->GetArmourClass());
      obj->ModifyHitPoints(deltaHp, unit, team/*, &dir*/);
    }
    else
    {
      F32 mod = 1.0f - (dist2 * areaDiff2Inv);
      ASSERT(mod >= 0 && mod <= 1.0f)

      // Apply a proportional damage to this object
      //Vector v = dir * mod;
      deltaHp = -(S32) (((F32) damage.GetAmount(obj->MapType()->GetArmourClass())) * mod);
      obj->ModifyHitPoints(deltaHp, unit, team/*, &v*/);
    }

    // Apply hit modifiers
    if (ArmourClass::Lookup(damage.GetDamageId(), obj->MapType()->GetArmourClass()))
    {
      damage.GetModifiers().Apply(obj);

      // Set blind target time
      if (blindTargetTime)
      {
        UnitObj *unitObj = Promote::Object<UnitObjType, UnitObj>(obj);

        if (unitObj)
        {
          unitObj->FlushTasks();
          unitObj->StartBlindTarget(blindTargetTime);
        }
      }

      // Apply the generic effect
      StartGenericFX(obj, 0x32FBA304); // "ExplosionObj::ApplyTarget"
    }

    // Is there an action to execute
    if (action && team)
    {
      Action::Execute(team, action);
    }
  }
}
开发者ID:ZhouWeikuan,项目名称:darkreign2,代码行数:62,代码来源:explosionobj.cpp

示例5: ERR_CONFIG

  //
  // Assign constructors to this base
  //
  void Base::AssignConstructors(const char *tagName)
  {
    processTokens = TRUE;

    // Was a tag specified ?
    if (tagName)
    {
      // Resolve the tag
      TagObj *tag = TagObj::FindTag(tagName);

      if (tag)
      {
        // Iterate the units in the tag
        for (MapObjList::Iterator i(&tag->list); *i; i++)
        {
          // Is it alive
          if (!(*i)->Alive())
          {
            continue;
          }

          // Is this a unit ?
          UnitObj *unit = Promote::Object<UnitObjType, UnitObj>(**i);
          if (!unit)
          {
            continue;
          }

          // Is it on our team ?
          if (unit->GetTeam() != GetObject().GetTeam())
          {
            continue;
          }

          // Is it a constructor ?
          if (!unit->HasProperty(0xDCDE71CD)) // "Ability::Construction"
          {
            continue;
          }

//          LOG_AI(("Assigning constructor [%d] '%s' to base '%s'", unit->Id(), unit->UnitType()->GetName(), GetName()))

          // Add this constructor to the list of idle constructors
          constructorsIdle.Append(unit);
        }
      }
      else
      {
        ERR_CONFIG(("Could not find tag '%s' when assign constructors to base '%s'", tagName, GetName()))
      }
    }
    else
    {
      // Iterate all of the units on this team
      for (NList<UnitObj>::Iterator u(&GetObject().GetTeam()->GetUnitObjects()); *u; u++)
开发者ID:grasmanek94,项目名称:darkreign2,代码行数:58,代码来源:strategic_base.cpp

示例6: object

    //
    // Data constructor
    //
    Objects::Data::Data(MapObj *o) : object(o)
    {
      type = object->MapType();
      matrix = object->WorldMatrix();
      zipped = object->GetFootInstance() ? TRUE : FALSE;

      UnitObj *unit = Promote::Object<UnitObjType, UnitObj>(object);

      if (unit)
      {
        team = unit->GetTeam();
      }
    }
开发者ID:ZhouWeikuan,项目名称:darkreign2,代码行数:16,代码来源:studio_history_objects.cpp

示例7: m

    //
    // Apply
    //
    void Tag::Apply()
    {
      MapObjList list;

      list.AppendList((const MapObjList &) script.GetSquad()->GetList());

      if (clear)
      {
        // Go through all of the tags and remove any units which are in the squad
        for (NBinTree<TagObj>::Iterator t(&TagObj::allTags); *t; t++)
        {
          // Iterate the objects in this tag
          MapObjList::Iterator m(&(*t)->list);
          
          while (MapObjListNode *node = m++)
          {
            UnitObj *unit;

            // Is this a unit
            if 
            (
              node->Alive() &&
              (unit = Promote::Object<UnitObjType, UnitObj>(*node)) != NULL
            )
            {
              // If this unit is in our squad, remove it
              if (unit->GetSquad() == script.GetSquad())
              {
                (*t)->list.Unlink(node);
              }
            }
          }
        }
      }

      if (append)
      {
        // Is there an existing tag with this name ?
        TagObj *tag = TagObj::FindTag(tagName.GetStr());

        if (tag)
        {
          // Append the units in the tag to the list
          list.AppendList(tag->list);
        }
      }

      TagObj::CreateTag(tagName.GetStr(), list);

      list.Clear();
    }
开发者ID:grasmanek94,项目名称:darkreign2,代码行数:54,代码来源:strategic_script_state_settings.cpp

示例8: Execute

    //
    // Execute
    //
    U32 SelfDestruct::Execute(const U8 *, Player &player)
    {
      // Tell each object to SelfDestruct
      for (UnitObjList::Iterator i(&player.GetSelectedList()); *i; i++)
      {
        // Get the unit
        UnitObj *unit = **i;

        // Ensure it can self destruct
        if (unit->HasProperty(0x54D4152A) && !unit->UnderConstruction()) // "Ability::SelfDestruct"
        {
          unit->SelfDestruct(TRUE, unit->GetTeam());
        }
      }

      return (sizeof (Data));
    }
开发者ID:grasmanek94,项目名称:darkreign2,代码行数:20,代码来源:orders_game_selfdestruct.cpp

示例9: return

  //
  // Submit asset requests directly to the manager
  //
  Bool Asset::Request::TypeBase::DirectEvaluation(Manager &manager)
  {
    // Iterate the units in the base an evaluate them
    if (base.Alive())
    {
      for (UnitObjList::Iterator u(&base->GetUnits()); *u; u++)
      {
        if ((*u)->Alive())
        {
          UnitObj *unit = **u;
          manager.Evaluation(*this, *unit, config->GetAmounts().Find(unit->GameType()->Id()) ? 1.0f : 0.0f);
        }
      }
    }

    return (TRUE);
  }
开发者ID:ZhouWeikuan,项目名称:darkreign2,代码行数:20,代码来源:strategic_asset_request_typebase.cpp

示例10: ASSERT

  //
  // Offer
  //
  // The given asset is being offered, do we want it ?
  //
  Bool Asset::Request::TypeBase::Offer(Asset &asset)
  {
    // Get the unit out of the asset
    UnitObj *unit = asset.GetUnit();
    ASSERT(unit)

    // Do we have enough of this type ?
    U32 type = unit->GameType()->Id();

    // We should only be offered this type if we asked for it
    ASSERT(config->GetAmount(type))

    // How many of this type do we currently have ?
    U32 *amount = amounts.Find(type);

    // Is this less that what we need ?
    return ((!amount || *amount < config->GetAmount(type)) ? TRUE : FALSE);
  }
开发者ID:ZhouWeikuan,项目名称:darkreign2,代码行数:23,代码来源:strategic_asset_request_typebase.cpp

示例11: Execute

    //
    // Execute
    //
    U32 Store::Execute(const U8 *data, Player &player)
    {
      const Data *d = (Data *) data;

      // Create an iterator
      for (UnitObjList::Iterator i(&player.GetSelectedList()); *i; i++)
      {
        // Get the unit
        UnitObj *unit = **i;

        // Is this a collector ?
        if (Tasks::UnitCollect *task = TaskCtrl::PromoteIdle<Tasks::UnitCollect>(unit))
        {
          // Should we search for a place to store the resource
          if (d->search)
          {
            task->Store();
          }
          else
          {
            // Convert ID into a pointer
            if (UnitObj *storeObj = Resolver::Object<UnitObj, UnitObjType>(d->object))
            {
              // If not updating the position, flush tasks incase moving or something
              if (!d->update && unit->GetActiveTask())
              {
                unit->FlushTasks();
              }

              // Tell this task about the new storage point
              task->SetStorageObject(storeObj, d->update);
            }
          }
        }
      }

      return (sizeof (Data));
    }
开发者ID:grasmanek94,项目名称:darkreign2,代码行数:41,代码来源:orders_game_store.cpp

示例12: StateInit

  //
  // Initial state
  //
  void MapDeath::StateInit()
  {
    // Stop the objects driver
    UnitObj *unitObj = Promote::Object<UnitObjType, UnitObj>(subject);

    if (unitObj)
    {
      if (unitObj->GetWeapon())
      {
        unitObj->GetWeapon()->HaltFire();
      }

      if (unitObj->CanEverMove())
      {
        unitObj->GetDriver()->Stop(Movement::Driver::STOP_DYING);
      }
    }

    // Play the death animation
    subject->SetAnimation(0xF40D135F); // "Death"

    NextState(0x382D3C63); // "Dead"
  }
开发者ID:ZhouWeikuan,项目名称:darkreign2,代码行数:26,代码来源:tasks_mapdeath.cpp

示例13: RenderSpecialized

    //
    // RenderSpecialized
    //
    // Display specialized unit information
    //
    static void RenderSpecialized()
    {
      // Is there a unit under the cursor
      UnitObj *over = data.cInfo.gameWnd.Alive() ? data.cInfo.o.unit.GetPointer() : NULL;

      // Can we see this units special info
      if (over && Team::TestDisplayRelation(over, Relation::ALLY))
      {
        over->RenderSpecialized();
      }

      // Now display for all selected units
      for (UnitObjList::Iterator i(&data.sList); *i; ++i)
      {
        if (UnitObj *u = (*i)->GetPointer())
        {
          if (u != over)
          {
            u->RenderSpecialized();
          }
        }
      }
    }
开发者ID:ZhouWeikuan,项目名称:darkreign2,代码行数:28,代码来源:client_display.cpp

示例14: IssueTask

//
// Execute
//
U32 PowerDown::Execute(const U8 *data, Player &player)
{
    const Data *d = (Data *) data;

    // Are we powering down or up
    if (d->down)
    {
        // Check each selected object
        for (UnitObjList::Iterator i(&player.GetSelectedList()); *i; i++)
        {
            UnitObj *subject = **i;

            // Can this unit power down ?
            if (subject->UnitType()->GetPower().GetRequired())
            {
                IssueTask(FLUSH, subject, new Tasks::UnitPowerDown(subject), player);
            }
        }
    }
    else
    {
        // Check each selected object
        for (UnitObjList::Iterator i(&player.GetSelectedList()); *i; i++)
        {
            UnitObj *subject = **i;

            // Is this unit powered down ?
            if (Tasks::UnitPowerDown *task = TaskCtrl::Promote<Tasks::UnitPowerDown>(subject))
            {
                task->ProcessEvent(Task::Event(0x57BE223A)); // "PowerUp"
            }
        }
    }

    return (sizeof (Data));
}
开发者ID:vgck,项目名称:opendr2,代码行数:39,代码来源:orders_game_powerdown.cpp

示例15: u

  //
  // StateInit
  //
  void SquadBoard::StateInit()
  {
    // Get each of the units in the squad to board transports
    SquadObj::UnitList::Iterator u(&subject->GetList());

    // We could enhance this to use units which are closest to transports etc.

    // Clear the squad's completed flags
    for (!u; *u; u++)
    {
      (*u)->completed = FALSE;
      (*u)->task = 0;
    }

    // Reset squad iterator
    !u;

    for (TransportObjList::Iterator t(&transports); *t; t++)
    {
      if ((*t)->Alive())
      {
        TransportObj *transport = **t;
        U32 slots = transport->TransportType()->GetSpaces();
        U32 added = 0;

        while (slots--)
        {
          UnitObjPtr *unitPtr = *u;

          if (unitPtr)
          {
            ASSERT(unitPtr->Alive())
            UnitObj *unit = *unitPtr;

            if (unit->CanEverMove())
            {
              // Tell the unit to board
              unit->FlushTasks(Tasks::UnitBoard::GetConfigBlockingPriority());

              Task *task;

              // Is this a telepad
              if (TaskCtrl::PromoteIdle<Tasks::TransportPad>(transport))
              {
                unit->PrependTask(task = new Tasks::UnitMove(unit, transport), GetFlags());
              }
              else
              {
                unit->PrependTask(task = new Tasks::UnitBoard(unit, transport), GetFlags());
              }

              (*u)->task = task->GetTaskId();

              added++;
            }
            else
            {
              // This unit can't move so complete it
              (*u)->completed = TRUE;
            }
          }
          else
          {
            break;
          }

          // Increment iterator
          u++;
        }

        if (!added)
        {
          // No units were added
          break;
        }
      }
    }

    // Complete those units which missed out
    for (; *u; u++)
    {
      (*u)->completed = TRUE;
    }

    NextState(0x09E5F977); // "Boarding"
  }
开发者ID:ZhouWeikuan,项目名称:darkreign2,代码行数:89,代码来源:tasks_squadboard.cpp


注:本文中的UnitObj类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。