コード例 #1
0
            public void Execute(int i)
            {
                var sc         = sphere_collider_list_[i];
                var center     = sc.position_;
                var hashCenter = GridHash.Hash(ref center, cell_radius_);

                hashmap_.Add(hashCenter, i);
                for (var j = 0; j < offsets_.Length; ++j)
                {
                    var offset = center + offsets_[j] * sc.radius_;
                    var hash   = GridHash.Hash(ref offset, cell_radius_);
                    if (hash != hashCenter)
                    {
                        hashmap_.Add(hash, i);
                    }
                }
            }
コード例 #2
0
            public void Execute(int i)
            {
                var coll0 = player_bullet_colliders_[i];
                int hash  = GridHash.Hash(ref coll0.position_, cell_radius_);
                int index;
                NativeMultiHashMapIterator <int> it;

                for (bool success = enemy_hashmap_.TryGetFirstValue(hash, out index, out it);
                     success;
                     success = enemy_hashmap_.TryGetNextValue(out index, ref it))
                {
                    var coll1 = enemy_colliders_[index];
                    if (coll0.intersect(ref coll1))
                    {
                        var mid_pos = (coll0.position_ + coll1.position_) * 0.5f;
                        player_bullet_collision_info_list_[i] = PlayerBulletCollisionInfo.Hit(ref mid_pos);
                        var enemy = enemy_list_[index];
                        enemy.life_.add(-5f);
                        break;
                    }
                }
            }
コード例 #3
0
            public void Execute(int i)
            {
                var coll0 = enemy_colliders_[i];
                int hash  = GridHash.Hash(ref coll0.position_, cell_radius_);
                int index;
                NativeMultiHashMapIterator <int> it;

                for (bool success = player_hashmap_.TryGetFirstValue(hash, out index, out it);
                     success;
                     success = player_hashmap_.TryGetNextValue(out index, ref it))
                {
                    var coll1 = player_colliders_[index];
                    if (coll0.intersect(ref coll1))
                    {
                        var enemy = enemy_list_[i];
                        enemy.life_.add(CV.MinValue); // kill
                        var player = player_list_[index];
                        player.life_.add(-99f);       // damage
                        break;
                    }
                }
            }